{"record":{"id":"dd2a1cd5f60aeb81","repo":"kubernetes/kops","slug":"vpc-with-id-q-not-found","errorCode":null,"errorMessage":"VPC with id %q not found","messagePattern":"VPC with id %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/vpc.go","lineNumber":183,"sourceCode":"\t\tif changes.CIDR != nil {\n\t\t\t// TODO: Do we want to destroy & recreate the VPC?\n\t\t\treturn fi.FieldIsImmutable(e.CIDR, a.CIDR, field.NewPath(\"CIDR\"))\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (e *VPC) Run(c *fi.CloudupContext) error {\n\treturn fi.CloudupDefaultDeltaRunMethod(e, c)\n}\n\nfunc (_ *VPC) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *VPC) error {\n\tctx := context.TODO()\n\tshared := fi.ValueOf(e.Shared)\n\tif shared {\n\t\t// Verify the VPC was found and matches our required settings\n\t\tif a == nil {\n\t\t\treturn fmt.Errorf(\"VPC with id %q not found\", fi.ValueOf(e.ID))\n\t\t}\n\n\t\tif changes != nil && changes.EnableDNSSupport != nil {\n\t\t\tif featureflag.VPCSkipEnableDNSSupport.Enabled() {\n\t\t\t\tklog.Warningf(\"VPC did not have EnableDNSSupport=true, but ignoring because of VPCSkipEnableDNSSupport feature-flag\")\n\t\t\t} else {\n\t\t\t\t// TODO: We could easily just allow kops to fix this...\n\t\t\t\treturn fmt.Errorf(\"VPC with id %q was set to be shared, but did not have EnableDNSSupport=true.\", fi.ValueOf(e.ID))\n\t\t\t}\n\t\t}\n\t}\n\n\tif a == nil {\n\t\tklog.V(2).Infof(\"Creating VPC with CIDR: %q\", *e.CIDR)\n\n\t\trequest := &ec2.CreateVpcInput{\n\t\t\tCidrBlock:         e.CIDR,\n\t\t\tTagSpecifications: awsup.EC2TagSpecification(ec2types.ResourceTypeVpc, e.Tags),","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/vpc.go#L165-L201","documentation":"In RenderAWS, when the VPC task is marked shared, kOps will not create the VPC; it only validates an existing one. If the actual (a) state is nil — no VPC matched the given ID/tags — it returns this error instead of creating anything.","triggerScenarios":"Task spec has shared=true but the referenced VPC ID does not exist (typo in cluster spec), was deleted, or is in a different region/account so lookup found nothing.","commonSituations":"Hand-edited cluster spec pointing at a removed VPC; cross-account/region mismatch; VPC deleted out-of-band after cluster spec was generated.","solutions":["Correct the VPC ID in the cluster spec (`kops edit cluster`) or remove shared:true to let kOps create the VPC","Verify the VPC exists: `aws ec2 describe-vpcs --vpc-ids <id>` in the target region/account","Re-run `kops update cluster` after fixing"],"exampleFix":"// before (shared, missing VPC)\nsharedVPC: vpc-0deadbeef\n// after: correct existing ID or unshare\nsharedVPC: vpc-0123456789abcdef0\n// or remove shared:true so kOps creates the VPC","handlingStrategy":"validation","validationCode":"vpcID := \"vpc-0123456789abcdef0\"\nout, err := ec2Client.DescribeVpcs(ctx, &ec2.DescribeVpcsInput{VpcIds: []string{vpcID}})\nif err != nil || len(out.Vpcs) == 0 {\n\treturn fmt.Errorf(\"VPC %s does not exist in region/account; fix cluster spec or unshare\", vpcID)\n}","typeGuard":"func sharedVPCResolvable(e *awstasks.VPC, a *awstasks.VPC) bool {\n\treturn !fi.ValueOf(e.Shared) || a != nil\n}","tryCatchPattern":"err := target.RenderAWS(task)\nif err != nil && strings.Contains(err.Error(), \"not found\") {\n\t// prompt: verify VPC ID in spec or set shared:false to create\n}","preventionTips":["Never hand-edit sharedVPC IDs; use `kops edit cluster` and validate","Run `aws ec2 describe-vpcs --vpc-ids` before pointing a spec at a shared VPC","Confirm region matches the VPC's region","After out-of-band VPC deletion, update or regenerate the cluster spec"],"tags":["aws","vpc","shared-vpc","config"],"backgroundTag":"shared-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"}