Skip to content

Commit

Permalink
Merge pull request #25190 from DrFaust92/ec2-vpc-end-ip-type
Browse files Browse the repository at this point in the history
r/vpc_endpoint - add `dns_options` and `ip_address_type` argument
  • Loading branch information
ewbankkit authored Jun 22, 2022
2 parents a954d75 + b516ead commit 9ad2e81
Show file tree
Hide file tree
Showing 12 changed files with 761 additions and 683 deletions.
7 changes: 7 additions & 0 deletions .changelog/25190.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/aws_vpc_endpoint: Add `dns_options` and `ip_address_type` arguments
```

```release-note:enhancement
data-source/aws_vpc_endpoint: Add `dns_options` and `ip_address_type` attributes
```
1 change: 1 addition & 0 deletions internal/service/ec2/ec2_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func testAccErrorCheckSkip(t *testing.T) resource.ErrorCheckFunc {
"Unsupported volume type",
"HostLimitExceeded",
"ReservationCapacityExceeded",
"InsufficientInstanceCapacity",
)
}

Expand Down
1 change: 1 addition & 0 deletions internal/service/ec2/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const (
errCodeInvalidPlacementGroupUnknown = "InvalidPlacementGroup.Unknown"
errCodeInvalidPoolIDNotFound = "InvalidPoolID.NotFound"
errCodeInvalidPrefixListIDNotFound = "InvalidPrefixListID.NotFound"
errCodeInvalidPrefixListIdNotFound = "InvalidPrefixListId.NotFound"
errCodeInvalidRouteNotFound = "InvalidRoute.NotFound"
errCodeInvalidRouteTableIDNotFound = "InvalidRouteTableID.NotFound"
errCodeInvalidRouteTableIdNotFound = "InvalidRouteTableId.NotFound"
Expand Down
69 changes: 69 additions & 0 deletions internal/service/ec2/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -2651,6 +2651,16 @@ func FindVPCEndpointServiceConfigurations(conn *ec2.EC2, input *ec2.DescribeVpcE
return output, nil
}

func FindVPCEndpointServiceConfigurationByServiceName(conn *ec2.EC2, name string) (*ec2.ServiceConfiguration, error) {
input := &ec2.DescribeVpcEndpointServiceConfigurationsInput{
Filters: BuildAttributeFilterList(map[string]string{
"service-name": name,
}),
}

return FindVPCEndpointServiceConfiguration(conn, input)
}

func FindVPCEndpointServices(conn *ec2.EC2, input *ec2.DescribeVpcEndpointServicesInput) ([]*ec2.ServiceDetail, []string, error) {
var serviceDetails []*ec2.ServiceDetail
var serviceNames []string
Expand Down Expand Up @@ -4705,6 +4715,65 @@ func FindPlacementGroupByName(conn *ec2.EC2, name string) (*ec2.PlacementGroup,
return placementGroup, nil
}

func FindPrefixList(conn *ec2.EC2, input *ec2.DescribePrefixListsInput) (*ec2.PrefixList, error) {
output, err := FindPrefixLists(conn, input)

if err != nil {
return nil, err
}

if len(output) == 0 || output[0] == nil {
return nil, tfresource.NewEmptyResultError(input)
}

if count := len(output); count > 1 {
return nil, tfresource.NewTooManyResultsError(count, input)
}

return output[0], nil
}

func FindPrefixLists(conn *ec2.EC2, input *ec2.DescribePrefixListsInput) ([]*ec2.PrefixList, error) {
var output []*ec2.PrefixList

err := conn.DescribePrefixListsPages(input, func(page *ec2.DescribePrefixListsOutput, lastPage bool) bool {
if page == nil {
return !lastPage
}

for _, v := range page.PrefixLists {
if v != nil {
output = append(output, v)
}
}

return !lastPage
})

if tfawserr.ErrCodeEquals(err, errCodeInvalidPrefixListIdNotFound) {
return nil, &resource.NotFoundError{
LastError: err,
LastRequest: input,
}
}

if err != nil {
return nil, err
}

return output, nil
}

func FindPrefixListByName(conn *ec2.EC2, name string) (*ec2.PrefixList, error) {
input := &ec2.DescribePrefixListsInput{
Filters: BuildAttributeFilterList(map[string]string{
"prefix-list-name": name,
}),
}

return FindPrefixList(conn, input)
}

func FindVPCEndpointConnectionByServiceIDAndVPCEndpointID(conn *ec2.EC2, serviceID, vpcEndpointID string) (*ec2.VpcEndpointConnection, error) {
input := &ec2.DescribeVpcEndpointConnectionsInput{
Filters: BuildAttributeFilterList(map[string]string{
Expand Down
Loading

0 comments on commit 9ad2e81

Please sign in to comment.