{"record":{"id":"fa4f134710813eb1","repo":"kubernetes/kops","slug":"error-clusters-cannot-span-multiple-regions-found","errorCode":null,"errorMessage":"error Clusters cannot span multiple regions (found zone %q, but region is %q)","messagePattern":"error Clusters cannot span multiple regions \\(found zone %q, but region is %q\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awsup/aws_utils.go","lineNumber":110,"sourceCode":"func FindRegion(cluster *kops.Cluster) (string, error) {\n\tregion := \"\"\n\n\tfor _, subnet := range cluster.Spec.Networking.Subnets {\n\t\tif subnet.Zone == \"\" {\n\t\t\t// The zone of a subnet specified by ID is looked up from the cloud later.\n\t\t\tif subnet.ID == \"\" {\n\t\t\t\treturn \"\", fmt.Errorf(\"subnet %q must specify a zone or the ID of an existing subnet\", subnet.Name)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif len(subnet.Zone) <= 2 {\n\t\t\treturn \"\", fmt.Errorf(\"invalid AWS zone: %q in subnet %q\", subnet.Zone, subnet.Name)\n\t\t}\n\n\t\tzoneRegion := subnet.Zone[:len(subnet.Zone)-1]\n\t\tif region != \"\" && zoneRegion != region {\n\t\t\treturn \"\", fmt.Errorf(\"error Clusters cannot span multiple regions (found zone %q, but region is %q)\", subnet.Zone, region)\n\t\t}\n\n\t\tregion = zoneRegion\n\t}\n\n\tif region == \"\" {\n\t\treturn \"\", fmt.Errorf(\"could not determine cluster region: no subnet specifies a zone\")\n\t}\n\n\treturn region, nil\n}\n\n// SupportsS3BootstrapEndpoint reports whether the region uses the amazonaws.com partition DNS\n// suffix hard-coded by the nodeup bootstrap script. EC2 uses the same partition suffix as S3 and\n// can be resolved without a bucket.\nfunc SupportsS3BootstrapEndpoint(ctx context.Context, region string) (bool, error) {\n\tresolver := ec2.NewDefaultEndpointResolverV2()\n\tendpoint, err := resolver.ResolveEndpoint(ctx, ec2.EndpointParameters{Region: aws.String(region)})","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awsup/aws_utils.go#L92-L128","documentation":"FindRegion infers the region from each subnet's zone (zone minus last character) and requires all zones to map to the same region, because a kops cluster cannot span multiple AWS regions. When a zone's derived region differs from the region already established by earlier subnets, this error is returned. (Note the literal message includes a leading 'error ' prefix from the format string.)","triggerScenarios":"Iterating subnets in FindRegion where subnet.Zone[:len-1] differs from the region derived from a previous subnet — e.g. zones us-east-1a and eu-west-1a in the same cluster spec.","commonSituations":"Copy-pasting subnet entries across example cluster manifests from different regions; merging cluster specs during migration; accidentally including an old region's subnets when renaming a cluster.","solutions":["Make all subnet zones belong to a single region in the cluster spec","Remove subnets from the other region, or create a separate cluster for that region","Re-run `kops update cluster` after fixing the spec"],"exampleFix":"// before\nsubnets:\n- name: a\n  zone: us-east-1a\n- name: b\n  zone: eu-west-1a\n// after\nsubnets:\n- name: a\n  zone: us-east-1a\n- name: b\n  zone: us-east-1b","handlingStrategy":"validation","validationCode":"regions := map[string]bool{}\nfor _, s := range cluster.Spec.Networking.Subnets {\n    if len(s.Zone) > 2 {\n        regions[s.Zone[:len(s.Zone)-1]] = true\n    }\n}\nif len(regions) > 1 { return fmt.Errorf(\"subnets span regions: %v\", regions) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep all subnets within one region; split cross-region needs into separate clusters","When copying example manifests, adjust all zones to your region","Add a CI check that derives one region from all zones"],"tags":["aws","region","zone","cluster-spec"],"backgroundTag":"cluster-spans-multiple-regions","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"}