{"record":{"id":"e255d3ded6fc111e","repo":"kubernetes/kops","slug":"error-describing-internetgateway-q-v","errorCode":null,"errorMessage":"error describing InternetGateway %q: %v","messagePattern":"error describing InternetGateway %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/aws/aws.go","lineNumber":1015,"sourceCode":"func DeleteInternetGateway(cloud fi.Cloud, r *resources.Resource) error {\n\tctx := context.TODO()\n\tc := cloud.(awsup.AWSCloud)\n\n\tid := r.ID\n\n\tvar igw *ec2types.InternetGateway\n\t{\n\t\trequest := &ec2.DescribeInternetGatewaysInput{\n\t\t\tInternetGatewayIds: []string{id},\n\t\t}\n\t\tresponse, err := c.EC2().DescribeInternetGateways(ctx, request)\n\t\tif err != nil {\n\t\t\tif awsup.AWSErrorCode(err) == \"InvalidInternetGatewayID.NotFound\" {\n\t\t\t\tklog.Infof(\"Internet gateway %q not found; assuming already deleted\", id)\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn fmt.Errorf(\"error describing InternetGateway %q: %v\", id, err)\n\t\t}\n\t\tif response == nil || len(response.InternetGateways) == 0 {\n\t\t\treturn nil\n\t\t}\n\t\tif len(response.InternetGateways) != 1 {\n\t\t\treturn fmt.Errorf(\"found multiple InternetGateways with id %q\", id)\n\t\t}\n\t\tigw = &response.InternetGateways[0]\n\t}\n\n\tfor _, a := range igw.Attachments {\n\t\tklog.V(2).Infof(\"Detaching EC2 InternetGateway %q\", id)\n\t\trequest := &ec2.DetachInternetGatewayInput{\n\t\t\tInternetGatewayId: &id,\n\t\t\tVpcId:             a.VpcId,\n\t\t}\n\t\t_, err := c.EC2().DetachInternetGateway(ctx, request)\n\t\tif err != nil {","sourceCodeStart":997,"sourceCodeEnd":1033,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/aws/aws.go#L997-L1033","documentation":"kOps wraps failures from the EC2 DescribeInternetGateways call made inside DeleteInternetGateway to fetch the gateway's attachments before detaching. NotFound is handled as already-deleted; any other describe failure is wrapped with the gateway ID.","triggerScenarios":"EC2 DescribeInternetGateways for the specific IGW ID fails with something other than InvalidInternetGatewayID.NotFound: malformed ID, throttling, auth failure, or network error.","commonSituations":"A hand-edited or stale resource tracker references an IGW ID that does not exist in a valid form; throttling during mass teardown; IAM missing ec2:DescribeInternetGateways.","solutions":["Validate the IGW ID with `aws ec2 describe-internet-gateways --internet-gateway-ids <id>`; fix or remove stale references in kOps state if the ID is malformed","On throttling, wait and retry the kOps delete","Check IAM permissions for ec2:DescribeInternetGateways","Re-run kOps delete; missing gateways are treated as already deleted"],"exampleFix":"// before: failing on any describe error\nreturn fmt.Errorf(\"error describing InternetGateway %q: %v\", id, err)\n// after: tolerate throttling with retry\nif awsup.AWSErrorCode(err) == \"Throttling\" {\n\ttime.Sleep(5 * time.Second)\n\tcontinue\n}","handlingStrategy":"validation","validationCode":"// validate the IGW ID format before calling delete\nif !strings.HasPrefix(id, \"igw-\") {\n\treturn fmt.Errorf(\"invalid internet gateway id %q\", id)\n}\nout, err := c.EC2().DescribeInternetGateways(ctx, &ec2.DescribeInternetGatewaysInput{\n\tInternetGatewayIds: []string{id},\n})\nif err != nil { return err }\nif len(out.InternetGateways) == 0 { return nil } // already deleted","typeGuard":"func validIGWID(s string) bool {\n\tre := regexp.MustCompile(`^igw-[0-9a-f]{8,17}$`)\n\treturn re.MatchString(s)\n}","tryCatchPattern":"if err != nil {\n\tif awsup.AWSErrorCode(err) == \"InvalidInternetGatewayID.NotFound\" {\n\t\treturn nil\n\t}\n\tif strings.Contains(err.Error(), \"Throttling\") {\n\t\treturn retryWithBackoff()\n\t}\n\treturn fmt.Errorf(\"error describing InternetGateway %q: %v\", id, err)\n}","preventionTips":["Sanity-check IGW IDs in kOps state before deletion (`kops toolbox dump`)","Ensure IAM includes ec2:DescribeInternetGateways","Use `aws ec2 describe-internet-gateways --internet-gateway-ids <id>` to pre-validate manually","Back off on throttling instead of tight-looping retries"],"tags":["aws","ec2","internet-gateway","describe"],"backgroundTag":"aws-api-request-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"}