{"record":{"id":"91e1d75e26c7ed02","repo":"kubernetes/kops","slug":"error-deleting-elastic-ip-q-v","errorCode":null,"errorMessage":"error deleting elastic ip %q: %v","messagePattern":"error deleting elastic ip %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/aws/aws.go","lineNumber":1746,"sourceCode":"\tc := cloud.(awsup.AWSCloud)\n\n\tid := t.ID\n\n\tklog.V(2).Infof(\"Releasing IP %s\", t.Name)\n\trequest := &ec2.ReleaseAddressInput{\n\t\tAllocationId: &id,\n\t}\n\t_, err := c.EC2().ReleaseAddress(ctx, request)\n\tif err != nil {\n\t\tif awsup.AWSErrorCode(err) == \"InvalidAllocationID.NotFound\" {\n\t\t\tklog.V(2).Infof(\"Got InvalidAllocationID.NotFound error deleting ElasticIP %q; will treat as already-deleted\", id)\n\t\t\treturn nil\n\t\t}\n\n\t\tif IsDependencyViolation(err) {\n\t\t\treturn err\n\t\t}\n\t\treturn fmt.Errorf(\"error deleting elastic ip %q: %v\", t.Name, err)\n\t}\n\treturn nil\n}\n\nfunc DeleteNatGateway(cloud fi.Cloud, t *resources.Resource) error {\n\tctx := context.TODO()\n\tc := cloud.(awsup.AWSCloud)\n\n\tid := t.ID\n\n\tklog.V(2).Infof(\"Removing NatGateway %s\", t.Name)\n\trequest := &ec2.DeleteNatGatewayInput{\n\t\tNatGatewayId: &id,\n\t}\n\t_, err := c.EC2().DeleteNatGateway(ctx, request)\n\tif err != nil {\n\t\tif IsDependencyViolation(err) {\n\t\t\treturn err","sourceCodeStart":1728,"sourceCodeEnd":1764,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/aws/aws.go#L1728-L1764","documentation":"DeleteElasticIP wraps a failed EC2 ReleaseAddress call for an EIP, formatted with the resource name. Dependency-violation errors (e.g. the EIP is still attached) are returned unwrapped for the tracker to retry; everything else becomes this wrapped error.","triggerScenarios":"ReleaseAddress fails: the EIP is still associated with a NAT gateway or instance (dependency violation path handles that separately), AuthFailure for invalid allocation ID, AccessDenied on ec2:ReleaseAddress, or the EIP was already released by another process.","commonSituations":"Deleting a cluster where the NAT gateway deletion hasn't completed before EIP release; EIP manually released via console while kOps was tearing down; missing ec2:ReleaseAddress IAM permission.","solutions":["Retry after the associated NAT gateway/instance is deleted — dependency violations are retried by the tracker automatically.","Verify the allocation ID still exists (aws ec2 describe-addresses); if already released, the next pass will converge.","Add ec2:ReleaseAddress to the IAM policy.","Check the wrapped %v for the exact AWS error (InvalidAllocationID.NotFound, AuthFailure, etc.).","Wait for AWS to finish async NAT gateway deletion before forcing EIP cleanup."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"addrs, err := c.EC2().DescribeAddresses(ctx, &ec2.DescribeAddressesInput{AllocationIds: []string{*t.ID}})\nif err != nil || len(addrs.Addresses) == 0 { /* already released; skip */ }\nif len(addrs.Addresses[0].AssociationId) > 0 { /* still associated; disassociate or wait for NGW deletion */ }","typeGuard":null,"tryCatchPattern":"if err := DeleteElasticIP(cloud, r); err != nil {\n    if awsup.AWSErrorCode(err) == \"InvalidAllocationID.NotFound\" { return nil // already gone }\n    return err // tracker will retry dependency violations\n}","preventionTips":["Delete the NAT gateway before releasing its EIP.","Check association state via DescribeAddresses before releasing.","Grant ec2:ReleaseAddress in IAM.","Treat InvalidAllocationID.NotFound as success on retries.","Pace teardown to avoid throttling."],"tags":["aws","ec2","elastic-ip","deletion"],"backgroundTag":"aws-api-delete-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"}