Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

b/aws_eip on delete error with ipam_pool_id stuck in IPAM eventual consistency loop #40082

Merged
merged 6 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/40082.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_eip: Properly surface errors during deletion when `ipam_pool_id` is set
```
16 changes: 8 additions & 8 deletions internal/service/ec2/ec2_eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,14 @@ func resourceEIPDelete(ctx context.Context, d *schema.ResourceData, meta interfa
log.Printf("[INFO] Deleting EC2 EIP: %s", d.Id())
_, err := conn.ReleaseAddress(ctx, input)

if tfawserr.ErrCodeEquals(err, errCodeInvalidAllocationIDNotFound) {
return diags
}

if err != nil {
return sdkdiag.AppendErrorf(diags, "deleting EC2 EIP (%s): %s", d.Id(), err)
}

// If the EIP's CIDR block was allocated from an IPAM pool, wait for the allocation to disappear.
if v, ok := d.GetOk("ipam_pool_id"); ok {
ipamPoolID := v.(string)
Expand All @@ -355,14 +363,6 @@ func resourceEIPDelete(ctx context.Context, d *schema.ResourceData, meta interfa
}
}

if tfawserr.ErrCodeEquals(err, errCodeInvalidAllocationIDNotFound) {
return diags
}

if err != nil {
return sdkdiag.AppendErrorf(diags, "deleting EC2 EIP (%s): %s", d.Id(), err)
}

return diags
}

Expand Down
Loading