{"record":{"id":"c16442a0dfbcfad5","repo":"kubernetes/kops","slug":"error-listing-internetgateways-v","errorCode":null,"errorMessage":"error listing InternetGateways: %v","messagePattern":"error listing InternetGateways: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/internetgateway.go","lineNumber":55,"sourceCode":"\tID  *string\n\tVPC *VPC\n\t// Shared is set if this is a shared InternetGateway\n\tShared *bool\n\n\t// Tags is a map of aws tags that are added to the InternetGateway\n\tTags map[string]string\n}\n\nvar _ fi.CompareWithID = (*InternetGateway)(nil)\n\nfunc (e *InternetGateway) CompareWithID() *string {\n\treturn e.ID\n}\n\nfunc findInternetGateway(ctx context.Context, cloud awsup.AWSCloud, request *ec2.DescribeInternetGatewaysInput) (*ec2types.InternetGateway, error) {\n\tresponse, err := cloud.EC2().DescribeInternetGateways(ctx, request)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing InternetGateways: %v\", err)\n\t}\n\tif response == nil || len(response.InternetGateways) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tif len(response.InternetGateways) != 1 {\n\t\treturn nil, fmt.Errorf(\"found multiple InternetGateways matching tags\")\n\t}\n\tigw := response.InternetGateways[0]\n\treturn &igw, nil\n}\n\nfunc (e *InternetGateway) Find(c *fi.CloudupContext) (*InternetGateway, error) {\n\tctx := c.Context()\n\tcloud := awsup.GetCloud(c)\n\n\trequest := &ec2.DescribeInternetGatewaysInput{}\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/internetgateway.go#L37-L73","documentation":"This error wraps any failure from the EC2 DescribeInternetGateways API call made while looking up an Internet Gateway in kOps' awstasks layer. It is thrown by findInternetGateway whenever AWS returns an error (auth, throttling, invalid filter/ID, network). It preserves the underlying AWS error via %v so the root cause is in the wrapped message.","triggerScenarios":"cloud.EC2().DescribeInternetGateways(ctx, request) returns non-nil err — e.g. invalid InternetGatewayIds, bad filter values, expired/insufficient IAM credentials, throttling, or network failure. Raised from both Find and RenderTerraform paths.","commonSituations":"Typo in shared IGW ID (igw-...), deleted gateway still referenced, IAM policy missing ec2:DescribeInternetGateways, AWS API throttling in large account, invalid tag filters passed by the caller.","solutions":["Read the wrapped AWS error: fix the specific cause (correct igw- ID, valid VPC filter, etc.).","Verify IAM credentials/policy allow ec2:DescribeInternetGateways.","If throttling, retry with exponential backoff.","Check AWS region configuration matches where the VPC/IGW exists."],"exampleFix":"// before: non-existent gateway ID in cluster spec\nsharedInternetGatewayID: igw-0abcdeadbeef12345\n// after: use the actual gateway ID from the shared VPC account\nsharedInternetGatewayID: igw-0f1e2d3c4b5a69788","handlingStrategy":"retry","validationCode":"// Validate credentials and IGW ID format before calling kops\nif !strings.HasPrefix(igwID, \"igw-\") {\n    return fmt.Errorf(\"invalid internet gateway id %q\", igwID)\n}\n// Ensure AWS creds resolve\n_, err := config.LoadDefaultCredentials(ctx)\nif err != nil {\n    return fmt.Errorf(\"no valid AWS credentials: %w\", err)\n}","typeGuard":"func hasWrappedAWSError(err error) bool {\n    var awsErr smithy.APIError\n    return errors.As(err, &awsErr)\n}","tryCatchPattern":"err := kopsUpdate(...)\nif err != nil && strings.Contains(err.Error(), \"error listing InternetGateways\") {\n    var awsErr smithy.APIError\n    if errors.As(err, &awsErr) && awsErr.ErrorCode() == \"Throttling\" {\n        time.Sleep(backoff)\n        // retry\n    }\n}","preventionTips":["Validate igw-/vpc- IDs referenced in specs actually exist via aws CLI before kops create.","Keep AWS credentials fresh and scoped with ec2:DescribeInternetGateways.","Add exponential backoff around kops operations in CI.","Run kops with the correct --region flag."],"tags":["aws","ec2","internet-gateway","api-error"],"backgroundTag":"aws-api-call-failed","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"}