{"record":{"id":"2fe6b03c1eda766f","repo":"kubernetes/kops","slug":"vpc-q-not-found","errorCode":null,"errorMessage":"VPC %q not found","messagePattern":"VPC %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/new_cluster.go","lineNumber":916,"sourceCode":"\t\t}\n\t}\n\n\treturn zoneToSubnetsMap, nil\n}\n\nfunc getAWSZoneToSubnetProviderID(VPCID string, region string, subnetIDs []string) (map[string]string, error) {\n\tres := make(map[string]string)\n\tcloudTags := map[string]string{}\n\tawsCloud, err := awsup.NewAWSCloud(region, cloudTags)\n\tif err != nil {\n\t\treturn res, fmt.Errorf(\"error loading cloud: %v\", err)\n\t}\n\tvpcInfo, err := awsCloud.FindVPCInfo(VPCID)\n\tif err != nil {\n\t\treturn res, fmt.Errorf(\"error describing VPC: %v\", err)\n\t}\n\tif vpcInfo == nil {\n\t\treturn res, fmt.Errorf(\"VPC %q not found\", VPCID)\n\t}\n\tsubnetByID := make(map[string]*fi.SubnetInfo)\n\tfor _, subnetInfo := range vpcInfo.Subnets {\n\t\tsubnetByID[subnetInfo.ID] = subnetInfo\n\t}\n\tfor _, subnetID := range subnetIDs {\n\t\tsubnet, ok := subnetByID[subnetID]\n\t\tif !ok {\n\t\t\treturn res, fmt.Errorf(\"subnet %s not found in VPC %s\", subnetID, VPCID)\n\t\t}\n\t\tif res[subnet.Zone] != \"\" {\n\t\t\treturn res, fmt.Errorf(\"subnet %s and %s have the same zone\", subnetID, res[subnet.Zone])\n\t\t}\n\t\tres[subnet.Zone] = subnetID\n\t}\n\treturn res, nil\n}\n","sourceCodeStart":898,"sourceCodeEnd":934,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/new_cluster.go#L898-L934","documentation":"FindVPCInfo returns (nil, nil) when the given VPC ID does not exist in the account/region — the API succeeds but nothing is found. kOps distinguishes this from an API failure and returns a dedicated \"VPC %q not found\" error so the user knows the VPC ID itself is wrong rather than the call failing.","triggerScenarios":"`kops create cluster --cloud aws --vpc vpc-0abc... --subnets subnet-...` where the VPC ID is mistyped, belongs to another region/account, was deleted, or comes from a shared-VPC account the caller cannot see.","commonSituations":"Copy-pasting a VPC ID from the wrong region console; typos like vpc-012345 vs vpc-543210; shared VPC visible only from the host account; VPC deleted between writing the script and running it.","solutions":["Verify the VPC ID with `aws ec2 describe-vpcs --vpc-ids vpc-xxx --region <region>` using the same credentials/region.","Correct the --vpc flag; ensure the region matches the VPC's region.","For shared VPCs, run kOps with credentials of an account that can describe the VPC, or confirm RAM sharing.","Check whether the VPC was deleted and pick a new one."],"exampleFix":"// before\n--vpc vpc-0olddeleted --region eu-west-1\n// after\n--vpc vpc-0correctid --region eu-west-1  # confirmed via aws ec2 describe-vpcs","handlingStrategy":"validation","validationCode":"out, err := exec.Command(\"aws\", \"ec2\", \"describe-vpcs\", \"--vpc-ids\", vpcID, \"--region\", region).Output()\nif err != nil || !strings.Contains(string(out), vpcID) {\n    return fmt.Errorf(\"VPC %s not visible in %s with current credentials\", vpcID, region)\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"VPC \\\"vpc-\") && strings.Contains(err.Error(), \"not found\") {\n    // prompt user to re-check --vpc ID, account, and region before retry\n}","preventionTips":["Resolve VPC IDs dynamically via aws CLI tags instead of hardcoding.","Always pass --region matching the VPC's region.","For shared VPCs, verify RAM sharing/visibility with the host account first."],"tags":["aws","vpc","not-found","cluster-creation"],"backgroundTag":"resource-not-found","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"}