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

r/vpc_endpoint_service - add supported_ip_address_types argument #25189

Merged
merged 24 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
561c22f
r/aws_vpc_endpoint_service_allowed_principal: Tidy up acceptance test.
ewbankkit Jun 28, 2021
419e077
Use 'aws_iam_session_context' to obtain issuer ARN.
ewbankkit Jun 28, 2021
d6578d6
add `supported_ip_address_types` arg
DrFaust92 Jun 6, 2022
effa1c0
add `supported_ip_address_types` arg
DrFaust92 Jun 6, 2022
88010e5
changelog
DrFaust92 Jun 6, 2022
7a23e2f
add to update list
DrFaust92 Jun 6, 2022
8f05159
changelog
DrFaust92 Jun 6, 2022
37f97ee
r/aws_vpc_endpoint_service: Start to tidy up resource Create.
ewbankkit Jun 20, 2022
f942f4c
Add 'FindVPCEndpointServices' and friends.
ewbankkit Jun 20, 2022
ecfbcea
r/aws_vpc_endpoint_service: Tidy up resource Create.
ewbankkit Jun 20, 2022
3b67a5a
r/aws_vpc_endpoint_service: Tidy up resource Delete.
ewbankkit Jun 20, 2022
be33e10
Additional error messages to skip.
ewbankkit Jun 21, 2022
d6e0a94
r/aws_vpc_endpoint_service: Tidy up resource Read.
ewbankkit Jun 21, 2022
b7c5b61
r/aws_vpc_endpoint_service: Tidy up resource Update.
ewbankkit Jun 21, 2022
97582a9
Fix typos in 'TestAccVPCEndpointService_networkLoadBalancerARNs'.
ewbankkit Jun 21, 2022
ba703a7
Generate paginator for 'DescribeVpcEndpointServices'.
ewbankkit Jun 21, 2022
07cba85
Revert "Use 'aws_iam_session_context' to obtain issuer ARN."
ewbankkit Jun 21, 2022
62d841a
Revert "r/aws_vpc_endpoint_service_allowed_principal: Tidy up accepta…
ewbankkit Jun 21, 2022
8a0b630
Merge branch 'main' into td-aws_vpc_endpoint_service_allowed_principa…
ewbankkit Jun 21, 2022
9b26579
Merge remote-tracking branch 'origin/td-aws_vpc_endpoint_service_allo…
ewbankkit Jun 21, 2022
039202f
Use 'aws_iam_session_context' to obtain issuer ARN.
ewbankkit Jun 21, 2022
30f2af6
r/aws_vpc_endpoint_service_allowed_principal: Tidy up.
ewbankkit Jun 21, 2022
6f8080e
d/aws_vpc_endpoint_service: Add 'supported_ip_address_types' attribute.
ewbankkit Jun 21, 2022
190a061
Rename EC2 error code constants to match API's capitalization.
ewbankkit Jun 21, 2022
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
7 changes: 7 additions & 0 deletions .changelog/25189.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/aws_vpc_endpoint_service: Add `supported_ip_address_types` argument
```

```release-note:enhancement
data-source/aws_vpc_endpoint_service: Add `supported_ip_address_types` attribute
```
2 changes: 2 additions & 0 deletions internal/service/ec2/ec2_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func testAccErrorCheckSkip(t *testing.T) resource.ErrorCheckFunc {
"You have reached the maximum allowed number of license configurations created in one day",
"specified zone does not support multi-attach-enabled volumes",
"Unsupported volume type",
"HostLimitExceeded",
"ReservationCapacityExceeded",
)
}

Expand Down
9 changes: 5 additions & 4 deletions internal/service/ec2/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const (
errCodeInvalidCapacityReservationIdNotFound = "InvalidCapacityReservationId.NotFound'"
ErrCodeInvalidCarrierGatewayIDNotFound = "InvalidCarrierGatewayID.NotFound"
errCodeInvalidClientVPNActiveAssociationNotFound = "InvalidClientVpnActiveAssociationNotFound"
errCodeInvalidClientVPNAssociationIDNotFound = "InvalidClientVpnAssociationIdNotFound"
errCodeInvalidClientVPNAssociationIdNotFound = "InvalidClientVpnAssociationIdNotFound"
errCodeInvalidClientVPNAuthorizationRuleNotFound = "InvalidClientVpnEndpointAuthorizationRuleNotFound"
errCodeInvalidClientVPNEndpointIDNotFound = "InvalidClientVpnEndpointId.NotFound"
errCodeInvalidClientVPNEndpointIdNotFound = "InvalidClientVpnEndpointId.NotFound"
errCodeInvalidClientVPNRouteNotFound = "InvalidClientVpnRouteNotFound"
ErrCodeInvalidConnectionNotification = "InvalidConnectionNotification"
errCodeInvalidConversionTaskIdMalformed = "InvalidConversionTaskId.Malformed"
Expand Down Expand Up @@ -61,6 +61,7 @@ const (
errCodeInvalidRouteTableIDNotFound = "InvalidRouteTableID.NotFound"
errCodeInvalidRouteTableIdNotFound = "InvalidRouteTableId.NotFound"
errCodeInvalidSecurityGroupIDNotFound = "InvalidSecurityGroupID.NotFound"
errCodeInvalidServiceName = "InvalidServiceName"
errCodeInvalidSnapshotInUse = "InvalidSnapshot.InUse"
errCodeInvalidSnapshotNotFound = "InvalidSnapshot.NotFound"
ErrCodeInvalidSpotDatafeedNotFound = "InvalidSpotDatafeed.NotFound"
Expand All @@ -76,9 +77,9 @@ const (
errCodeInvalidTransitGatewayMulticastDomainIdNotFound = "InvalidTransitGatewayMulticastDomainId.NotFound"
errCodeInvalidVolumeNotFound = "InvalidVolume.NotFound"
errCodeInvalidVPCCIDRBlockAssociationIDNotFound = "InvalidVpcCidrBlockAssociationID.NotFound"
errCodeInvalidVPCEndpointIDNotFound = "InvalidVpcEndpointId.NotFound"
errCodeInvalidVPCEndpointIdNotFound = "InvalidVpcEndpointId.NotFound"
errCodeInvalidVPCEndpointNotFound = "InvalidVpcEndpoint.NotFound"
errCodeInvalidVPCEndpointServiceIDNotFound = "InvalidVpcEndpointServiceId.NotFound"
errCodeInvalidVPCEndpointServiceIdNotFound = "InvalidVpcEndpointServiceId.NotFound"
errCodeInvalidVPCIDNotFound = "InvalidVpcID.NotFound"
errCodeInvalidVPCPeeringConnectionIDNotFound = "InvalidVpcPeeringConnectionID.NotFound"
errCodeInvalidVPNConnectionIDNotFound = "InvalidVpnConnectionID.NotFound"
Expand Down
186 changes: 178 additions & 8 deletions internal/service/ec2/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func FindClientVPNEndpoints(conn *ec2.EC2, input *ec2.DescribeClientVpnEndpoints
return !lastPage
})

if tfawserr.ErrCodeEquals(err, errCodeInvalidClientVPNEndpointIDNotFound) {
if tfawserr.ErrCodeEquals(err, errCodeInvalidClientVPNEndpointIdNotFound) {
return nil, &resource.NotFoundError{
LastError: err,
LastRequest: input,
Expand Down Expand Up @@ -303,7 +303,7 @@ func FindClientVPNAuthorizationRules(conn *ec2.EC2, input *ec2.DescribeClientVpn
return !lastPage
})

if tfawserr.ErrCodeEquals(err, errCodeInvalidClientVPNEndpointIDNotFound) {
if tfawserr.ErrCodeEquals(err, errCodeInvalidClientVPNEndpointIdNotFound) {
return nil, &resource.NotFoundError{
LastError: err,
LastRequest: input,
Expand Down Expand Up @@ -369,7 +369,7 @@ func FindClientVPNNetworkAssociations(conn *ec2.EC2, input *ec2.DescribeClientVp
return !lastPage
})

if tfawserr.ErrCodeEquals(err, errCodeInvalidClientVPNEndpointIDNotFound, errCodeInvalidClientVPNAssociationIDNotFound) {
if tfawserr.ErrCodeEquals(err, errCodeInvalidClientVPNEndpointIdNotFound, errCodeInvalidClientVPNAssociationIdNotFound) {
return nil, &resource.NotFoundError{
LastError: err,
LastRequest: input,
Expand Down Expand Up @@ -449,7 +449,7 @@ func FindClientVPNRoutes(conn *ec2.EC2, input *ec2.DescribeClientVpnRoutesInput)
return !lastPage
})

if tfawserr.ErrCodeEquals(err, errCodeInvalidClientVPNEndpointIDNotFound) {
if tfawserr.ErrCodeEquals(err, errCodeInvalidClientVPNEndpointIdNotFound) {
return nil, &resource.NotFoundError{
LastError: err,
LastRequest: input,
Expand Down Expand Up @@ -2560,7 +2560,7 @@ func FindVPCEndpoints(conn *ec2.EC2, input *ec2.DescribeVpcEndpointsInput) ([]*e
return !lastPage
})

if tfawserr.ErrCodeEquals(err, errCodeInvalidVPCEndpointIDNotFound) {
if tfawserr.ErrCodeEquals(err, errCodeInvalidVPCEndpointIdNotFound) {
return nil, &resource.NotFoundError{
LastError: err,
LastRequest: input,
Expand All @@ -2574,9 +2574,9 @@ func FindVPCEndpoints(conn *ec2.EC2, input *ec2.DescribeVpcEndpointsInput) ([]*e
return output, nil
}

func FindVPCEndpointByID(conn *ec2.EC2, vpcEndpointID string) (*ec2.VpcEndpoint, error) {
func FindVPCEndpointByID(conn *ec2.EC2, id string) (*ec2.VpcEndpoint, error) {
input := &ec2.DescribeVpcEndpointsInput{
VpcEndpointIds: aws.StringSlice([]string{vpcEndpointID}),
VpcEndpointIds: aws.StringSlice([]string{id}),
}

output, err := FindVPCEndpoint(conn, input)
Expand All @@ -2593,7 +2593,7 @@ func FindVPCEndpointByID(conn *ec2.EC2, vpcEndpointID string) (*ec2.VpcEndpoint,
}

// Eventual consistency check.
if aws.StringValue(output.VpcEndpointId) != vpcEndpointID {
if aws.StringValue(output.VpcEndpointId) != id {
return nil, &resource.NotFoundError{
LastRequest: input,
}
Expand All @@ -2602,6 +2602,176 @@ func FindVPCEndpointByID(conn *ec2.EC2, vpcEndpointID string) (*ec2.VpcEndpoint,
return output, nil
}

func FindVPCEndpointServiceConfiguration(conn *ec2.EC2, input *ec2.DescribeVpcEndpointServiceConfigurationsInput) (*ec2.ServiceConfiguration, error) {
output, err := FindVPCEndpointServiceConfigurations(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 FindVPCEndpointServiceConfigurations(conn *ec2.EC2, input *ec2.DescribeVpcEndpointServiceConfigurationsInput) ([]*ec2.ServiceConfiguration, error) {
var output []*ec2.ServiceConfiguration

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

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

return !lastPage
})

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

if err != nil {
return nil, err
}

return output, nil
}

func FindVPCEndpointServices(conn *ec2.EC2, input *ec2.DescribeVpcEndpointServicesInput) ([]*ec2.ServiceDetail, []string, error) {
var serviceDetails []*ec2.ServiceDetail
var serviceNames []string

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

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

for _, v := range page.ServiceNames {
serviceNames = append(serviceNames, aws.StringValue(v))
}

return !lastPage
})

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

if err != nil {
return nil, nil, err
}

return serviceDetails, serviceNames, nil
}

func FindVPCEndpointServiceConfigurationByID(conn *ec2.EC2, id string) (*ec2.ServiceConfiguration, error) {
input := &ec2.DescribeVpcEndpointServiceConfigurationsInput{
ServiceIds: aws.StringSlice([]string{id}),
}

output, err := FindVPCEndpointServiceConfiguration(conn, input)

if err != nil {
return nil, err
}

if state := aws.StringValue(output.ServiceState); state == ec2.ServiceStateDeleted || state == ec2.ServiceStateFailed {
return nil, &resource.NotFoundError{
Message: state,
LastRequest: input,
}
}

// Eventual consistency check.
if aws.StringValue(output.ServiceId) != id {
return nil, &resource.NotFoundError{
LastRequest: input,
}
}

return output, nil
}

func FindVPCEndpointServicePermissions(conn *ec2.EC2, input *ec2.DescribeVpcEndpointServicePermissionsInput) ([]*ec2.AllowedPrincipal, error) {
var output []*ec2.AllowedPrincipal

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

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

return !lastPage
})

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

if err != nil {
return nil, err
}

return output, nil
}

func FindVPCEndpointServicePermissionsByID(conn *ec2.EC2, id string) ([]*ec2.AllowedPrincipal, error) {
input := &ec2.DescribeVpcEndpointServicePermissionsInput{
ServiceId: aws.String(id),
}

return FindVPCEndpointServicePermissions(conn, input)
}

func FindVPCEndpointServicePermissionExists(conn *ec2.EC2, serviceID, principalARN string) error {
allowedPrincipals, err := FindVPCEndpointServicePermissionsByID(conn, serviceID)

if err != nil {
return err
}

for _, v := range allowedPrincipals {
if aws.StringValue(v.Principal) == principalARN {
return nil
}
}

return &resource.NotFoundError{
LastError: fmt.Errorf("VPC Endpoint Service (%s) Principal (%s) not found", serviceID, principalARN),
}
}

// FindVPCEndpointRouteTableAssociationExists returns NotFoundError if no association for the specified VPC endpoint and route table IDs is found.
func FindVPCEndpointRouteTableAssociationExists(conn *ec2.EC2, vpcEndpointID string, routeTableID string) error {
vpcEndpoint, err := FindVPCEndpointByID(conn, vpcEndpointID)
Expand Down
2 changes: 1 addition & 1 deletion internal/service/ec2/generate.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//go:generate go run ../../generate/tagresource/main.go -IDAttribName=resource_id
//go:generate go run ../../generate/tags/main.go -GetTag -ListTags -ListTagsOp=DescribeTags -ListTagsInFiltIDName=resource-id -ListTagsInIDElem=Resources -ServiceTagsSlice -TagOp=CreateTags -TagInIDElem=Resources -TagInIDNeedSlice=yes -TagType2=TagDescription -UntagOp=DeleteTags -UntagInNeedTagType -UntagInTagsElem=Tags -UpdateTags
//go:generate go run generate/createtags/main.go
//go:generate go run ../../generate/listpages/main.go -ListOps=DescribeSpotFleetInstances,DescribeSpotFleetRequestHistory
//go:generate go run ../../generate/listpages/main.go -ListOps=DescribeSpotFleetInstances,DescribeSpotFleetRequestHistory,DescribeVpcEndpointServices
// ONLY generate directives and package declaration! Do not add anything else to this file.

package ec2
23 changes: 22 additions & 1 deletion internal/service/ec2/list_pages_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions internal/service/ec2/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,41 @@ func StatusVPCEndpointState(conn *ec2.EC2, id string) resource.StateRefreshFunc
}
}

func StatusVPCEndpointServiceStateAvailable(conn *ec2.EC2, id string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
// Don't call FindVPCEndpointServiceConfigurationByID as it maps useful status codes to NotFoundError.
output, err := FindVPCEndpointServiceConfiguration(conn, &ec2.DescribeVpcEndpointServiceConfigurationsInput{
ServiceIds: aws.StringSlice([]string{id}),
})

if tfresource.NotFound(err) {
return nil, "", nil
}

if err != nil {
return nil, "", err
}

return output, aws.StringValue(output.ServiceState), nil
}
}

func StatusVPCEndpointServiceStateDeleted(conn *ec2.EC2, id string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
output, err := FindVPCEndpointServiceConfigurationByID(conn, id)

if tfresource.NotFound(err) {
return nil, "", nil
}

if err != nil {
return nil, "", err
}

return output, aws.StringValue(output.ServiceState), nil
}
}

const (
VPCEndpointRouteTableAssociationStatusReady = "ready"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/service/ec2/vpc_endpoint_connection_accepter.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func resourceVPCEndpointConnectionAccepterDelete(d *schema.ResourceData, meta in

_, err = conn.RejectVpcEndpointConnections(input)

if tfawserr.ErrCodeEquals(err, errCodeInvalidVPCEndpointServiceIDNotFound) {
if tfawserr.ErrCodeEquals(err, errCodeInvalidVPCEndpointServiceIdNotFound) {
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func resourceVPCEndpointRouteTableAssociationDelete(d *schema.ResourceData, meta
log.Printf("[DEBUG] Deleting VPC Endpoint Route Table Association: %s", id)
_, err := conn.ModifyVpcEndpoint(input)

if tfawserr.ErrCodeEquals(err, errCodeInvalidVPCEndpointIDNotFound) || tfawserr.ErrCodeEquals(err, errCodeInvalidRouteTableIdNotFound) || tfawserr.ErrCodeEquals(err, errCodeInvalidParameter) {
if tfawserr.ErrCodeEquals(err, errCodeInvalidVPCEndpointIdNotFound) || tfawserr.ErrCodeEquals(err, errCodeInvalidRouteTableIdNotFound) || tfawserr.ErrCodeEquals(err, errCodeInvalidParameter) {
return nil
}

Expand Down
Loading