Skip to content

Commit 05a5e23

Browse files
committed
aws_eip: 'findIPAMPoolAllocationsForEIP' is redundant.
1 parent b329aa9 commit 05a5e23

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

internal/service/ec2/ec2_eip.go

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ import (
1616
awstypes "github.com/aws/aws-sdk-go-v2/service/ec2/types"
1717
"github.com/hashicorp/aws-sdk-go-base/v2/tfawserr"
1818
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
19-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
2019
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
2120
"github.com/hashicorp/terraform-provider-aws/internal/conns"
2221
"github.com/hashicorp/terraform-provider-aws/internal/enum"
2322
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
24-
tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices"
2523
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
2624
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
2725
"github.com/hashicorp/terraform-provider-aws/names"
@@ -339,7 +337,7 @@ func resourceEIPDelete(ctx context.Context, d *schema.ResourceData, meta any) di
339337
timeout = 10 * time.Minute // IPAM eventual consistency
340338
)
341339
_, err := tfresource.RetryUntilNotFound(ctx, timeout, func(ctx context.Context) (any, error) {
342-
return findIPAMPoolAllocationsForEIP(ctx, conn, ipamPoolID, d.Get("allocation_id").(string))
340+
return findIPAMPoolAllocationsByIPAMPoolIDAndResourceID(ctx, conn, ipamPoolID, d.Get("allocation_id").(string))
343341
})
344342

345343
if err != nil {
@@ -430,25 +428,3 @@ func disassociateEIP(ctx context.Context, conn *ec2.Client, associationID string
430428
func eipARN(ctx context.Context, c *conns.AWSClient, allocationID string) string {
431429
return c.RegionalARN(ctx, names.EC2, "elastic-ip/"+allocationID)
432430
}
433-
434-
func findIPAMPoolAllocationsForEIP(ctx context.Context, conn *ec2.Client, ipamPoolID, eipAllocationID string) ([]awstypes.IpamPoolAllocation, error) {
435-
input := ec2.GetIpamPoolAllocationsInput{
436-
IpamPoolId: aws.String(ipamPoolID),
437-
}
438-
439-
output, err := findIPAMPoolAllocations(ctx, conn, &input)
440-
441-
if err != nil {
442-
return nil, err
443-
}
444-
445-
output = tfslices.Filter(output, func(v awstypes.IpamPoolAllocation) bool {
446-
return v.ResourceType == awstypes.IpamPoolAllocationResourceTypeEip && aws.ToString(v.ResourceId) == eipAllocationID
447-
})
448-
449-
if len(output) == 0 {
450-
return nil, &retry.NotFoundError{}
451-
}
452-
453-
return output, nil
454-
}

0 commit comments

Comments
 (0)