{"record":{"id":"26d23d973761cfd0","repo":"kubernetes/kops","slug":"error-listing-all-internetgateways-v","errorCode":null,"errorMessage":"error listing (all) InternetGateways: %v","messagePattern":"error listing \\(all\\) InternetGateways: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/aws/aws.go","lineNumber":1132,"sourceCode":"\n\tvar gateways []ec2types.InternetGateway\n\tgateways = append(gateways, response.InternetGateways...)\n\n\treturn gateways, nil\n}\n\n// DescribeInternetGatewaysIgnoreTags returns all ec2.InternetGateways, ignoring tags\n// (gateways were not always tagged in kube-up)\nfunc DescribeInternetGatewaysIgnoreTags(cloud fi.Cloud) ([]ec2types.InternetGateway, error) {\n\tctx := context.TODO()\n\tc := cloud.(awsup.AWSCloud)\n\n\tklog.V(2).Infof(\"Listing all Internet Gateways\")\n\n\trequest := &ec2.DescribeInternetGatewaysInput{}\n\tresponse, err := c.EC2().DescribeInternetGateways(ctx, request)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing (all) InternetGateways: %v\", err)\n\t}\n\n\tvar gateways []ec2types.InternetGateway\n\n\tgateways = append(gateways, response.InternetGateways...)\n\n\treturn gateways, nil\n}\n\nfunc DumpEgressOnlyInternetGateway(op *resources.DumpOperation, r *resources.Resource) error {\n\tdata := make(map[string]interface{})\n\tdata[\"id\"] = r.ID\n\tdata[\"type\"] = r.Type\n\tdata[\"raw\"] = r.Obj\n\top.Dump.Resources = append(op.Dump.Resources, data)\n\treturn nil\n}\n","sourceCodeStart":1114,"sourceCodeEnd":1150,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/aws/aws.go#L1114-L1150","documentation":"kops wraps a failed EC2 DescribeInternetGateways call when listing all internet gateways in a region/VPC during cluster resource enumeration. The underlying AWS SDK error (auth, throttling, network, invalid filter) is embedded with %v, losing the error chain. It is thrown from DescribeInternetGatewaysIgnoreTags, invoked by ListResourcesAWS during `kops delete cluster --dry-run` style enumeration.","triggerScenarios":"EC2 DescribeInternetGateways returns any non-nil error: expired/missing credentials, ThrottlingException, network timeout, or invalid region configuration in the AWSCloud client.","commonSituations":"Running `kops delete cluster` with stale AWS credentials; API rate limits when scanning many clusters; VPC/endpoints blocking ec2.<region>.amazonaws.com.","solutions":["Run `aws ec2 describe-internet-gateways` with the same credentials/region to reproduce and identify the underlying error.","Refresh credentials (aws sso login / re-export keys) and confirm AWS_REGION / cluster region match.","If throttled, reduce concurrent kops API calls or retry after backoff.","Verify network path (VPN/proxy/VPC endpoint) can reach the EC2 endpoint."],"exampleFix":"// before\nreturn nil, fmt.Errorf(\"error listing (all) InternetGateways: %v\", err)\n// after\nreturn nil, fmt.Errorf(\"error listing (all) InternetGateways: %w\", err)","handlingStrategy":"retry","validationCode":"sess, err := session.NewSession(); _, err = sts.New(sess).GetCallerIdentity(&sts.GetCallerIdentityInput{}); if err != nil { /* fix credentials before listing */ }","typeGuard":"func isThrottling(err error) bool { var ae smithy.APIError; return errors.As(err, &ae) && ae.ErrorCode() == \"ThrottlingException\" }","tryCatchPattern":"gateways, err := DescribeInternetGatewaysIgnoreTags(cloud)\nif err != nil {\n\tif isThrottling(err) { /* backoff and retry */ }\n\treturn fmt.Errorf(\"internet gateway listing failed: %w\", err)\n}","preventionTips":["Verify credentials/region with `aws sts get-caller-identity` before kops runs","Keep IAM policies current with kops' documented EC2 permissions","Add exponential backoff for throttling-prone enumeration phases"],"tags":["aws","ec2","internet-gateway","api-error"],"backgroundTag":"aws-ec2-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"}