Skip to content

Commit 382c4a4

Browse files
committed
r/aws_vpc: Move finder functions.
1 parent 05a5e23 commit 382c4a4

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

internal/service/ec2/find.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4055,6 +4055,28 @@ func findIPAMPoolAllocationsByIPAMPoolIDAndResourceID(ctx context.Context, conn
40554055
}), nil
40564056
}
40574057

4058+
func findIPAMPoolAllocationsForVPC(ctx context.Context, conn *ec2.Client, poolID, vpcID string) ([]awstypes.IpamPoolAllocation, error) {
4059+
input := &ec2.GetIpamPoolAllocationsInput{
4060+
IpamPoolId: aws.String(poolID),
4061+
}
4062+
4063+
output, err := findIPAMPoolAllocations(ctx, conn, input)
4064+
4065+
if err != nil {
4066+
return nil, err
4067+
}
4068+
4069+
output = tfslices.Filter(output, func(v awstypes.IpamPoolAllocation) bool {
4070+
return v.ResourceType == awstypes.IpamPoolAllocationResourceTypeVpc && aws.ToString(v.ResourceId) == vpcID
4071+
})
4072+
4073+
if len(output) == 0 {
4074+
return nil, &retry.NotFoundError{}
4075+
}
4076+
4077+
return output, nil
4078+
}
4079+
40584080
func findIPAMPoolCIDR(ctx context.Context, conn *ec2.Client, input *ec2.GetIpamPoolCidrsInput) (*awstypes.IpamPoolCidr, error) {
40594081
output, err := findIPAMPoolCIDRs(ctx, conn, input)
40604082

internal/service/ec2/vpc_.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ 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-plugin-sdk/v2/helper/validation"
2221
"github.com/hashicorp/terraform-provider-aws/internal/conns"
@@ -716,28 +715,6 @@ func modifyVPCTenancy(ctx context.Context, conn *ec2.Client, vpcID string, v str
716715
return nil
717716
}
718717

719-
func findIPAMPoolAllocationsForVPC(ctx context.Context, conn *ec2.Client, poolID, vpcID string) ([]awstypes.IpamPoolAllocation, error) {
720-
input := &ec2.GetIpamPoolAllocationsInput{
721-
IpamPoolId: aws.String(poolID),
722-
}
723-
724-
output, err := findIPAMPoolAllocations(ctx, conn, input)
725-
726-
if err != nil {
727-
return nil, err
728-
}
729-
730-
output = tfslices.Filter(output, func(v awstypes.IpamPoolAllocation) bool {
731-
return v.ResourceType == awstypes.IpamPoolAllocationResourceTypeVpc && aws.ToString(v.ResourceId) == vpcID
732-
})
733-
734-
if len(output) == 0 {
735-
return nil, &retry.NotFoundError{}
736-
}
737-
738-
return output, nil
739-
}
740-
741718
func vpcARN(ctx context.Context, c *conns.AWSClient, accountID, vpcID string) string {
742719
return c.RegionalARNWithAccount(ctx, names.EC2, accountID, "vpc/"+vpcID)
743720
}

0 commit comments

Comments
 (0)