{"record":{"id":"ad03707d3e8b3c6f","repo":"kubernetes/kops","slug":"cannot-select-instance-types-from-non-aws-cluster","errorCode":null,"errorMessage":"cannot select instance types from non-aws cluster","messagePattern":"cannot select instance types from non-aws cluster","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/toolbox_instance-selector.go","lineNumber":242,"sourceCode":"\tcommandline.IntFlag(maxResults, nil, &maxResultsDefault, \"Maximum number of instance types to return back\")\n\tcommandline.BoolFlag(dryRun, nil, &dryRunDefault, \"Only print the object that would be created, without creating it. This flag can be used to create a cluster YAML or JSON manifest.\")\n\tcommandline.StringFlag(output, commandline.StringMe(\"o\"), &outputDefault, \"Output format. One of json or yaml. Used with the --dry-run flag.\", nil)\n\tcommandline.Command.RegisterFlagCompletionFunc(output, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {\n\t\treturn []string{\"json\", \"yaml\"}, cobra.ShellCompDirectiveNoFileComp\n\t})\n\n\treturn commandline.Command\n}\n\n// RunToolboxInstanceSelector executes the instance-selector tool to create instance groups with declarative resource specifications\nfunc RunToolboxInstanceSelector(ctx context.Context, f commandutils.Factory, out io.Writer, commandline *cli.CommandLineInterface, options *InstanceSelectorOptions) error {\n\tclientset, cluster, channel, err := retrieveClusterRefs(ctx, f, options.ClusterName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif cluster.GetCloudProvider() != kops.CloudProviderAWS {\n\t\treturn fmt.Errorf(\"cannot select instance types from non-aws cluster\")\n\t}\n\n\tfirstClusterSubnet := strings.ReplaceAll(cluster.Spec.Networking.Subnets[0].Name, \"utility-\", \"\")\n\tregion := firstClusterSubnet[:len(firstClusterSubnet)-1]\n\n\tigSubnets := []string{}\n\tfor _, clusterSubnet := range cluster.Spec.Networking.Subnets {\n\t\tigSubnets = append(igSubnets, clusterSubnet.Name)\n\t}\n\n\tif commandline.Flags[subnets] != nil {\n\t\tuserSubnets := *commandline.StringSliceMe(commandline.Flags[subnets])\n\t\tdryRun := *commandline.BoolMe(commandline.Flags[dryRun])\n\t\terr := validateUserSubnets(userSubnets, cluster.Spec.Networking.Subnets)\n\t\tif err != nil && !dryRun {\n\t\t\treturn err\n\t\t}\n\t\tigSubnets = userSubnets","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/toolbox_instance-selector.go#L224-L260","documentation":"`kops toolbox instance-selector` computes AWS EC2 instance-type recommendations (via AWS instance type data and pricing) and is only implemented for AWS clusters. RunToolboxInstanceSelector retrieves the cluster and rejects any cluster whose cloudProvider is not kops.CloudProviderAWS with this error.","triggerScenarios":"Running `kops toolbox instance-selector` against a cluster whose spec has cloudProvider set to gce, hetzner, openstack, digitalocean, azure, etc.","commonSituations":"Mixed-fleet operators running an AWS-oriented workflow against a GCP/Hetzner cluster; copying commands from AWS-focused docs; a mis-set cloudProvider in the cluster spec.","solutions":["Point --name at an AWS cluster","For other clouds, size instances with the provider's own tooling (e.g. GCE machine recommendations)","Check the cluster spec: kops get cluster <name> -o yaml | grep cloudProvider"],"exampleFix":"// before\nkops toolbox instance-selector nodes --name gcp-cluster.example.com\n// error: cannot select instance types from non-aws cluster\n// after — target an AWS cluster\nkops toolbox instance-selector nodes --name aws-cluster.k8s.local","handlingStrategy":"validation","validationCode":"PROVIDER=$(kops get cluster \"$CLUSTER\" -o json | jq -r '.spec.cloudProvider.type // .spec.cloudProvider')\nif [ \"$PROVIDER\" != \"aws\" ]; then\n  echo \"instance-selector requires an AWS cluster (got: $PROVIDER)\" >&2\n  exit 3\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check the cluster's cloudProvider before AWS-specific tooling","Keep separate scripts per cloud provider","Document cloud assumptions in shared automation"],"tags":["cli","aws","instance-selector","unsupported-cloud"],"backgroundTag":"cloud-provider-not-supported","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}