{"record":{"id":"cd535906452a26e5","repo":"kubernetes/kops","slug":"error-deleting-egressonlyinternetgateway-q-v","errorCode":null,"errorMessage":"error deleting EgressOnlyInternetGateway %q: %v","messagePattern":"error deleting EgressOnlyInternetGateway %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/aws/aws.go","lineNumber":1171,"sourceCode":"\tc := cloud.(awsup.AWSCloud)\n\n\tid := r.ID\n\n\t{\n\t\tklog.V(2).Infof(\"Deleting EC2 EgressOnlyInternetGateway %q\", id)\n\t\trequest := &ec2.DeleteEgressOnlyInternetGatewayInput{\n\t\t\tEgressOnlyInternetGatewayId: &id,\n\t\t}\n\t\t_, err := c.EC2().DeleteEgressOnlyInternetGateway(ctx, request)\n\t\tif err != nil {\n\t\t\tif IsDependencyViolation(err) {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif awsup.AWSErrorCode(err) == \"InvalidEgressOnlyInternetGatewayID.NotFound\" {\n\t\t\t\tklog.Infof(\"Egress-only internet gateway %q not found; assuming already deleted\", id)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"error deleting EgressOnlyInternetGateway %q: %v\", id, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc ListEgressOnlyInternetGateways(cloud fi.Cloud, vpcID, clusterName string) ([]*resources.Resource, error) {\n\tgateways, err := DescribeEgressOnlyInternetGateways(cloud)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar resourceTrackers []*resources.Resource\n\n\tfor _, o := range gateways {\n\t\tresourceTracker := &resources.Resource{\n\t\t\tName:    FindName(o.Tags),\n\t\t\tID:      aws.ToString(o.EgressOnlyInternetGatewayId),","sourceCodeStart":1153,"sourceCodeEnd":1189,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/aws/aws.go#L1153-L1189","documentation":"Thrown when EC2 DeleteEgressOnlyInternetGateway fails with any error other than InvalidEgressOnlyInternetGatewayID.NotFound. Dependency violations (e.g. routes still referencing the gateway) are passed through; everything else is wrapped with the gateway ID. Indicates the IPv6 egress-only gateway could not be removed during cluster teardown.","triggerScenarios":"Calling DeleteEgressOnlyInternetGateway on an ID that is still attached to a subnet or referenced by a route table; permission denied on ec2:DeleteEgressOnlyInternetGateway; transient throttling.","commonSituations":"kops delete cluster blocked because a custom route still points at the egress-only IGW; IAM policy scoped too narrowly; gateway already deleted concurrently but ID malformed.","solutions":["Delete route table entries referencing the egress-only internet gateway, then retry the delete.","Check the embedded AWS error code: AuthFailure/UnauthorizedOperation means fix IAM permissions.","If throttling, wait and re-run kops delete cluster (it is idempotent due to the NotFound check).","Verify the gateway ID format (eigw-...) via `aws ec2 describe-egress-only-internet-gateways`."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"out, err := ec2Client.DescribeEgressOnlyInternetGateways(ctx, &ec2.DescribeEgressOnlyInternetGatewaysInput{EgressOnlyInternetGatewayIds: []string{id}}); if err != nil || len(out.EgressOnlyInternetGateways) == 0 { /* skip delete */ }","typeGuard":"func isDependencyViolation(err error) bool { return strings.Contains(err.Error(), \"DependencyViolation\") }","tryCatchPattern":"if err := DeleteEgressOnlyInternetGateway(cloud, r); err != nil {\n\tvar retryErr *resources.DirtyError\n\tif errors.As(err, &retryErr) { /* retry after routes removed */ }\n\tlog.Printf(\"eigw %s: %v\", r.ID, err)\n}","preventionTips":["Ensure route tables no longer reference the egress-only IGW before teardown","Use kops' own error-code checks (InvalidEgressOnlyInternetGatewayID.NotFound is already handled)","Make deletes idempotent — re-running kops delete cluster is safe"],"tags":["aws","ec2","ipv6","egress-only-internet-gateway","deletion"],"backgroundTag":"aws-dependency-violation","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"}