{"record":{"id":"180dc07107e68b58","repo":"kubernetes/kops","slug":"error-listing-vpcs-v-180dc0","errorCode":null,"errorMessage":"error listing VPCs: %v","messagePattern":"error listing VPCs: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/vpc.go","lineNumber":85,"sourceCode":"func (e *VPC) CompareWithID() *string {\n\treturn e.ID\n}\n\nfunc (e *VPC) Find(c *fi.CloudupContext) (*VPC, error) {\n\tctx := c.Context()\n\tcloud := awsup.GetCloud(c)\n\n\trequest := &ec2.DescribeVpcsInput{}\n\n\tif fi.ValueOf(e.ID) != \"\" {\n\t\trequest.VpcIds = []string{aws.ToString(e.ID)}\n\t} else {\n\t\trequest.Filters = cloud.BuildFilters(e.Name)\n\t}\n\n\tresponse, err := cloud.EC2().DescribeVpcs(ctx, request)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing VPCs: %v\", err)\n\t}\n\tif response == nil || len(response.Vpcs) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tif len(response.Vpcs) != 1 {\n\t\treturn nil, fmt.Errorf(\"found multiple VPCs matching tags\")\n\t}\n\tvpc := response.Vpcs[0]\n\tactual := &VPC{\n\t\tID:         vpc.VpcId,\n\t\tCIDR:       vpc.CidrBlock,\n\t\tAmazonIPv6: aws.Bool(false),\n\t\tName:       findNameTag(vpc.Tags),\n\t\tTags:       intersectTags(vpc.Tags, e.Tags),\n\t}\n\n\tklog.V(4).Infof(\"found matching VPC %v\", actual)","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/vpc.go#L67-L103","documentation":"VPC.Find lists VPCs via EC2 DescribeVpcs (by ID or by name/tag filters built from e.Name) and wraps any API error with this message. It means the DescribeVpcs call itself failed, not that zero or multiple VPCs matched.","triggerScenarios":"`kops update cluster`/reconciliation calling VPC.Find when EC2 DescribeVpcs errors: invalid filter syntax, missing ec2:DescribeVpcs permission, throttling, or region/credential problems.","commonSituations":"IAM roles missing ec2:DescribeVpcs; wrong AWS region or expired credentials; API throttling on large applies; malformed cluster name producing an invalid filter value.","solutions":["Read the wrapped %v cause for the AWS error code and fix accordingly","Verify credentials/region (aws sts get-caller-identity) and that the kops IAM policy includes ec2:DescribeVpcs","Re-run the command after transient throttling/5xx errors"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-flight: credentials + permission\n// aws ec2 describe-vpcs --region <region> --filters Name=tag:KubernetesCluster,Values=<cluster>","typeGuard":null,"tryCatchPattern":"if err := kopsUpdate(); err != nil && strings.Contains(err.Error(), \"error listing VPCs\") {\n  var ae smithy.APIError\n  if errors.As(err, &ae) && ae.ErrorCode() == \"ThrottlingException\" {\n    return retryAfter(backoff)\n  }\n  return fmt.Errorf(\"check AWS credentials/region and ec2:DescribeVpcs IAM: %w\", err)\n}","preventionTips":["Run `aws sts get-caller-identity` before apply to validate credentials/region","Include ec2:DescribeVpcs in the kops IAM policy","Back off and retry on throttling","Keep cluster names filter-safe (no invalid characters)"],"tags":["aws","ec2","vpc","describe"],"backgroundTag":"aws-api-describe-failed","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"}