{"record":{"id":"1c5008ff79dea33a","repo":"kubernetes/kops","slug":"subnet-q-has-configured-zone-q-but-the-actual-z","errorCode":null,"errorMessage":"Subnet %q has configured Zone %q, but the actual Zone found was %q","messagePattern":"Subnet %q has configured Zone %q, but the actual Zone found was %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/subnets.go","lineNumber":101,"sourceCode":"\t\t\tif subnet.ID != \"\" {\n\t\t\t\tcloudSubnet := subnetByID[subnet.ID]\n\t\t\t\tif cloudSubnet == nil {\n\t\t\t\t\treturn fmt.Errorf(\"Subnet %q not found in VPC %q\", subnet.ID, c.Spec.Networking.NetworkID)\n\t\t\t\t}\n\t\t\t\tif subnet.CIDR == \"\" {\n\t\t\t\t\tsubnet.CIDR = cloudSubnet.CIDR\n\t\t\t\t\t// IPv6-only private subnets do not have an IPv4 CIDR\n\t\t\t\t\tif subnet.CIDR == \"\" && (subnet.IPv6CIDR == \"\" || subnet.Type != kops.SubnetTypePrivate) {\n\t\t\t\t\t\treturn fmt.Errorf(\"Subnet %q did not have CIDR\", subnet.ID)\n\t\t\t\t\t}\n\t\t\t\t} else if subnet.CIDR != cloudSubnet.CIDR {\n\t\t\t\t\treturn fmt.Errorf(\"Subnet %q has configured CIDR %q, but the actual CIDR found was %q\", subnet.ID, subnet.CIDR, cloudSubnet.CIDR)\n\t\t\t\t}\n\n\t\t\t\tif needZones && subnet.Zone == \"\" {\n\t\t\t\t\tsubnet.Zone = cloudSubnet.Zone\n\t\t\t\t} else if subnet.Zone != cloudSubnet.Zone {\n\t\t\t\t\treturn fmt.Errorf(\"Subnet %q has configured Zone %q, but the actual Zone found was %q\", subnet.ID, subnet.Zone, cloudSubnet.Zone)\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\t}\n\n\tif needZones {\n\t\tfor i := range c.Spec.Networking.Subnets {\n\t\t\tsubnet := &c.Spec.Networking.Subnets[i]\n\t\t\tif subnet.ID != \"\" && subnet.Zone == \"\" {\n\t\t\t\treturn fmt.Errorf(\"could not determine the zone of subnet %q; specify the zone in the cluster spec\", subnet.Name)\n\t\t\t}\n\t\t}\n\t}\n\n\tif allSubnetsHaveCIDRs(c) {\n\t\tklog.V(4).Infof(\"All subnets have CIDRs; skipping assignment logic\")\n\t\treturn nil","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/subnets.go#L83-L119","documentation":"The cluster spec declares an availability zone for a subnet referenced by ID, but the actual AWS subnet resides in a different zone. Zone determines instance placement, so kOps refuses to silently override the spec with the cloud's zone.","triggerScenarios":"Cluster spec sets `zone: us-east-1a` on a subnet whose ID is actually in us-east-1b (or vice versa), typically after copying subnet entries between clusters or reusing IDs from another region's plan.","commonSituations":"Spec generated for one region reused in another; subnet IDs swapped in a template; hand-edits of zones to work around capacity issues without changing the subnet ID.","solutions":["Check the subnet's actual AZ (`aws ec2 describe-subnets --subnet-ids subnet-xxxx --query 'Subnets[].AvailabilityZone'`) and set the spec's `zone` to match.","Or remove the `zone` field so kOps derives it from the cloud (AWS subnets by ID).","Or point the subnet at an ID in the zone you actually want."],"exampleFix":"// before\nsubnets:\n- id: subnet-0abc\n  zone: us-east-1a   # actual AZ: us-east-1b\n// after\nsubnets:\n- id: subnet-0abc\n  zone: us-east-1b","handlingStrategy":"validation","validationCode":"actualAZ := describeSubnetAZ(subnetID, region)\nif subnet.Zone != \"\" && subnet.Zone != actualAZ {\n    return fmt.Errorf(\"zone %s != cloud AZ %s for %s\", subnet.Zone, actualAZ, subnetID)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Let kOps derive the zone for ID-referenced AWS subnets instead of hardcoding it.","Never reuse cluster specs across regions without regenerating subnet entries.","Include AZ checks in pre-apply validation scripts."],"tags":["subnet","zones","aws","config-validation"],"backgroundTag":"subnet-zone-mismatch","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}