{"record":{"id":"c60ff3bbe7a71de2","repo":"kubernetes/kops","slug":"subnet-q-not-found-in-vpc-q","errorCode":null,"errorMessage":"Subnet %q not found in VPC %q","messagePattern":"Subnet %q not found in VPC %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/subnets.go","lineNumber":86,"sourceCode":"\n\t\tvpcInfo, err := cloud.FindVPCInfo(c.Spec.Networking.NetworkID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif vpcInfo == nil {\n\t\t\treturn fmt.Errorf(\"VPC %q not found\", c.Spec.Networking.NetworkID)\n\t\t}\n\n\t\tsubnetByID := make(map[string]*fi.SubnetInfo)\n\t\tfor _, subnetInfo := range vpcInfo.Subnets {\n\t\t\tsubnetByID[subnetInfo.ID] = subnetInfo\n\t\t}\n\t\tfor i := range c.Spec.Networking.Subnets {\n\t\t\tsubnet := &c.Spec.Networking.Subnets[i]\n\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}","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/subnets.go#L68-L104","documentation":"kOps resolved the configured VPC successfully, but one of the cluster's subnets specified by ID (`subnet.ID`) was not among the VPC's subnets returned by the cloud. The subnet either does not exist, was deleted, or lives in a different VPC/region.","triggerScenarios":"Cluster spec lists subnets with explicit IDs (e.g. `id: subnet-xxxx`) that are not in `networking.networkID`; the subnet was deleted; wrong region for the API query; credentials cannot describe subnets.","commonSituations":"Shared-VPC setups where the subnet list was copied from another cluster; subnet deleted by another team's automation; moving a cluster spec between regions without updating subnet IDs.","solutions":["Verify each subnet ID: `aws ec2 describe-subnets --subnet-ids subnet-xxxx` and confirm its VPC matches networkID.","Remove or correct the stale subnet entry in the cluster spec, then run `kops update cluster`.","If subnets are shared cross-account, ensure the credentials used by kOps can list them."],"exampleFix":"// before\nsubnets:\n- id: subnet-0123456789deadbeef\n// after (existing subnet in the VPC)\nsubnets:\n- id: subnet-0abcdef1234567890","handlingStrategy":"validation","validationCode":"out, err := exec.Command(\"aws\", \"ec2\", \"describe-subnets\", \"--subnet-ids\", subnetID,\n    \"--filters\", \"Name=vpc-id,Values=\"+vpcID, \"--region\", region).Output()\nif err != nil || len(out) == 0 {\n    return fmt.Errorf(\"subnet %s not found in VPC %s\", subnetID, vpcID)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cross-check every subnet ID belongs to the specified VPC before applying the spec.","Avoid hardcoding subnet IDs in templates shared across regions/accounts.","Watch for automation that deletes subnets out-of-band."],"tags":["subnet","vpc","aws","networking"],"backgroundTag":"subnet-not-found","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"}