Skip to content

Commit

Permalink
Merge pull request #22339 from hashicorp/td-aws_subnet-modernize
Browse files Browse the repository at this point in the history
EC2 Subnet: Add DNS64, IPv6-only and Resource-based Name attributes
  • Loading branch information
ewbankkit authored Dec 24, 2021
2 parents b9abf1a + cf999f2 commit 44e4255
Show file tree
Hide file tree
Showing 31 changed files with 1,187 additions and 698 deletions.
7 changes: 7 additions & 0 deletions .changelog/22339.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/aws_subnet: Add `enable_dns64`, `ipv6_native`, `enable_resource_name_dns_aaaa_record_on_launch`, `enable_resource_name_dns_a_record_on_launch` and `private_dns_hostname_type_on_launch` arguments
```

```release-note:enhancement
data-source/aws_subnet: Add `enable_dns64`, `ipv6_native`, `enable_resource_name_dns_aaaa_record_on_launch`, `enable_resource_name_dns_a_record_on_launch` and `private_dns_hostname_type_on_launch` attributes
```
4 changes: 2 additions & 2 deletions internal/service/ec2/client_vpn_authorization_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func resourceClientVPNAuthorizationRuleRead(d *schema.ResourceData, meta interfa
d.Get("access_group_id").(string),
)

if tfawserr.ErrMessageContains(err, ErrCodeClientVPNAuthorizationRuleNotFound, "") {
if tfawserr.ErrMessageContains(err, ErrCodeClientVpnAuthorizationRuleNotFound, "") {
log.Printf("[WARN] EC2 Client VPN authorization rule (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
Expand Down Expand Up @@ -171,7 +171,7 @@ func deleteClientVpnAuthorizationRule(conn *ec2.EC2, input *ec2.RevokeClientVpnI
aws.StringValue(input.AccessGroupId))

_, err := conn.RevokeClientVpnIngress(input)
if tfawserr.ErrMessageContains(err, ErrCodeClientVPNAuthorizationRuleNotFound, "") {
if tfawserr.ErrMessageContains(err, ErrCodeClientVpnAuthorizationRuleNotFound, "") {
return nil
}
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/ec2/client_vpn_authorization_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func testAccCheckClientVPNAuthorizationRuleDestroy(s *terraform.State) error {
if err == nil {
return fmt.Errorf("Client VPN authorization rule (%s) still exists", rs.Primary.ID)
}
if tfawserr.ErrMessageContains(err, tfec2.ErrCodeClientVPNAuthorizationRuleNotFound, "") || tfawserr.ErrMessageContains(err, tfec2.ErrCodeClientVPNEndpointIdNotFound, "") {
if tfawserr.ErrMessageContains(err, tfec2.ErrCodeClientVpnAuthorizationRuleNotFound, "") || tfawserr.ErrMessageContains(err, tfec2.ErrCodeClientVpnEndpointIdNotFound, "") {
continue
}
return err
Expand Down
4 changes: 2 additions & 2 deletions internal/service/ec2/client_vpn_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func resourceClientVPNEndpointRead(d *schema.ResourceData, meta interface{}) err
ClientVpnEndpointIds: []*string{aws.String(d.Id())},
})

if tfawserr.ErrMessageContains(err, ErrCodeClientVPNAssociationIdNotFound, "") || tfawserr.ErrMessageContains(err, ErrCodeClientVPNEndpointIdNotFound, "") {
if tfawserr.ErrMessageContains(err, ErrCodeClientVpnAssociationIdNotFound, "") || tfawserr.ErrMessageContains(err, ErrCodeClientVpnEndpointIdNotFound, "") {
log.Printf("[WARN] EC2 Client VPN Endpoint (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
Expand Down Expand Up @@ -449,7 +449,7 @@ func DeleteClientVPNEndpoint(conn *ec2.EC2, endpointID string) error {
_, err := conn.DeleteClientVpnEndpoint(&ec2.DeleteClientVpnEndpointInput{
ClientVpnEndpointId: aws.String(endpointID),
})
if tfawserr.ErrMessageContains(err, ErrCodeClientVPNEndpointIdNotFound, "") {
if tfawserr.ErrMessageContains(err, ErrCodeClientVpnEndpointIdNotFound, "") {
return nil
}
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/service/ec2/client_vpn_network_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func resourceClientVPNNetworkAssociationRead(d *schema.ResourceData, meta interf
AssociationIds: []*string{aws.String(d.Id())},
})

if tfawserr.ErrMessageContains(err, ErrCodeClientVPNAssociationIdNotFound, "") || tfawserr.ErrMessageContains(err, ErrCodeClientVPNEndpointIdNotFound, "") {
if tfawserr.ErrMessageContains(err, ErrCodeClientVpnAssociationIdNotFound, "") || tfawserr.ErrMessageContains(err, ErrCodeClientVpnEndpointIdNotFound, "") {
log.Printf("[WARN] EC2 Client VPN Network Association (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
Expand Down Expand Up @@ -176,7 +176,7 @@ func DeleteClientVPNNetworkAssociation(conn *ec2.EC2, networkAssociationID, clie
AssociationId: aws.String(networkAssociationID),
})

if tfawserr.ErrMessageContains(err, ErrCodeClientVPNAssociationIdNotFound, "") || tfawserr.ErrMessageContains(err, ErrCodeClientVPNEndpointIdNotFound, "") {
if tfawserr.ErrMessageContains(err, ErrCodeClientVpnAssociationIdNotFound, "") || tfawserr.ErrMessageContains(err, ErrCodeClientVpnEndpointIdNotFound, "") {
return nil
}
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/service/ec2/client_vpn_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func resourceClientVPNRouteRead(d *schema.ResourceData, meta interface{}) error
d.Get("destination_cidr_block").(string),
)

if tfawserr.ErrMessageContains(err, ErrCodeClientVPNRouteNotFound, "") {
if tfawserr.ErrMessageContains(err, ErrCodeClientVpnRouteNotFound, "") {
log.Printf("[WARN] EC2 Client VPN Route (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
Expand Down Expand Up @@ -148,7 +148,7 @@ func deleteClientVpnRoute(conn *ec2.EC2, input *ec2.DeleteClientVpnRouteInput) e
)

_, err := conn.DeleteClientVpnRoute(input)
if tfawserr.ErrMessageContains(err, ErrCodeClientVPNRouteNotFound, "") {
if tfawserr.ErrMessageContains(err, ErrCodeClientVpnRouteNotFound, "") {
return nil
}
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/ec2/client_vpn_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func testAccCheckClientVPNRouteDestroy(s *terraform.State) error {
if err == nil {
return fmt.Errorf("Client VPN route (%s) still exists", rs.Primary.ID)
}
if tfawserr.ErrMessageContains(err, tfec2.ErrCodeClientVPNRouteNotFound, "") {
if tfawserr.ErrMessageContains(err, tfec2.ErrCodeClientVpnRouteNotFound, "") {
continue
}
}
Expand Down
14 changes: 7 additions & 7 deletions internal/service/ec2/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ func CPUCredits_Values() []string {

const (
// https://docs.aws.amazon.com/vpc/latest/privatelink/vpce-interface.html#vpce-interface-lifecycle
VPCEndpointStateAvailable = "available"
VPCEndpointStateDeleted = "deleted"
VPCEndpointStateDeleting = "deleting"
VPCEndpointStateFailed = "failed"
VPCEndpointStatePending = "pending"
VPCEndpointStatePendingAcceptance = "pendingAcceptance"
VPCEndpointStateRejected = "rejected"
VpcEndpointStateAvailable = "available"
VpcEndpointStateDeleted = "deleted"
VpcEndpointStateDeleting = "deleting"
VpcEndpointStateFailed = "failed"
VpcEndpointStatePending = "pending"
VpcEndpointStatePendingAcceptance = "pendingAcceptance"
VpcEndpointStateRejected = "rejected"
)

// See https://docs.aws.amazon.com/vm-import/latest/userguide/vmimport-image-import.html#check-import-task-status
Expand Down
140 changes: 40 additions & 100 deletions internal/service/ec2/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,107 +10,47 @@ import (
)

const (
ErrCodeDependencyViolation = "DependencyViolation"
ErrCodeGatewayNotAttached = "Gateway.NotAttached"
ErrCodeInvalidAssociationIDNotFound = "InvalidAssociationID.NotFound"
ErrCodeInvalidAttachmentIDNotFound = "InvalidAttachmentID.NotFound"
ErrCodeInvalidKeyPairNotFound = "InvalidKeyPair.NotFound"
ErrCodeInvalidParameter = "InvalidParameter"
ErrCodeInvalidParameterException = "InvalidParameterException"
ErrCodeInvalidParameterValue = "InvalidParameterValue"
)

const (
ErrCodeInvalidCarrierGatewayIDNotFound = "InvalidCarrierGatewayID.NotFound"
)

const (
ErrCodeClientInvalidHostIDNotFound = "Client.InvalidHostID.NotFound"
ErrCodeInvalidHostIDNotFound = "InvalidHostID.NotFound"
)

const (
ErrCodeInvalidInternetGatewayIDNotFound = "InvalidInternetGatewayID.NotFound"
)

const (
ErrCodeInvalidNetworkInterfaceIDNotFound = "InvalidNetworkInterfaceID.NotFound"
)

const (
ErrCodeInvalidPrefixListIDNotFound = "InvalidPrefixListID.NotFound"
)

const (
ErrCodeInvalidRouteNotFound = "InvalidRoute.NotFound"
ErrCodeInvalidRouteTableIdNotFound = "InvalidRouteTableId.NotFound"
ErrCodeInvalidRouteTableIDNotFound = "InvalidRouteTableID.NotFound"
)

const (
ErrCodeInvalidTransitGatewayIDNotFound = "InvalidTransitGatewayID.NotFound"
)

const (
ErrCodeClientVPNEndpointIdNotFound = "InvalidClientVpnEndpointId.NotFound"
ErrCodeClientVPNAuthorizationRuleNotFound = "InvalidClientVpnEndpointAuthorizationRuleNotFound"
ErrCodeClientVPNAssociationIdNotFound = "InvalidClientVpnAssociationId.NotFound"
ErrCodeClientVPNRouteNotFound = "InvalidClientVpnRouteNotFound"
)

const (
ErrCodeInvalidInstanceIDNotFound = "InvalidInstanceID.NotFound"
)

const (
InvalidSecurityGroupIDNotFound = "InvalidSecurityGroupID.NotFound"
InvalidGroupNotFound = "InvalidGroup.NotFound"
)

const (
ErrCodeInvalidSpotInstanceRequestIDNotFound = "InvalidSpotInstanceRequestID.NotFound"
)

const (
ErrCodeInvalidSubnetIdNotFound = "InvalidSubnetId.NotFound"
ErrCodeInvalidSubnetIDNotFound = "InvalidSubnetID.NotFound"
)

const (
ErrCodeInvalidVPCIDNotFound = "InvalidVpcID.NotFound"
)

const (
ErrCodeInvalidVPCEndpointIdNotFound = "InvalidVpcEndpointId.NotFound"
ErrCodeInvalidVPCEndpointNotFound = "InvalidVpcEndpoint.NotFound"
ErrCodeInvalidVPCEndpointServiceIdNotFound = "InvalidVpcEndpointServiceId.NotFound"
)

const (
ErrCodeInvalidVPCPeeringConnectionIDNotFound = "InvalidVpcPeeringConnectionID.NotFound"
)

const (
InvalidVPNGatewayAttachmentNotFound = "InvalidVpnGatewayAttachment.NotFound"
InvalidVPNGatewayIDNotFound = "InvalidVpnGatewayID.NotFound"
)

const (
ErrCodeInvalidPermissionDuplicate = "InvalidPermission.Duplicate"
ErrCodeInvalidPermissionMalformed = "InvalidPermission.Malformed"
ErrCodeInvalidPermissionNotFound = "InvalidPermission.NotFound"
)

const (
ErrCodeInvalidFlowLogIdNotFound = "InvalidFlowLogId.NotFound"
)

const (
ErrCodeInvalidPlacementGroupUnknown = "InvalidPlacementGroup.Unknown"
)

const (
ErrCodeClientInvalidHostIDNotFound = "Client.InvalidHostID.NotFound"
ErrCodeClientVpnAssociationIdNotFound = "InvalidClientVpnAssociationId.NotFound"
ErrCodeClientVpnAuthorizationRuleNotFound = "InvalidClientVpnEndpointAuthorizationRuleNotFound"
ErrCodeClientVpnEndpointIdNotFound = "InvalidClientVpnEndpointId.NotFound"
ErrCodeClientVpnRouteNotFound = "InvalidClientVpnRouteNotFound"
ErrCodeDependencyViolation = "DependencyViolation"
ErrCodeGatewayNotAttached = "Gateway.NotAttached"
ErrCodeInvalidAssociationIDNotFound = "InvalidAssociationID.NotFound"
ErrCodeInvalidAttachmentIDNotFound = "InvalidAttachmentID.NotFound"
ErrCodeInvalidCarrierGatewayIDNotFound = "InvalidCarrierGatewayID.NotFound"
ErrCodeInvalidFlowLogIdNotFound = "InvalidFlowLogId.NotFound"
ErrCodeInvalidGroupNotFound = "InvalidGroup.NotFound"
ErrCodeInvalidHostIDNotFound = "InvalidHostID.NotFound"
ErrCodeInvalidInstanceIDNotFound = "InvalidInstanceID.NotFound"
ErrCodeInvalidInternetGatewayIDNotFound = "InvalidInternetGatewayID.NotFound"
ErrCodeInvalidKeyPairNotFound = "InvalidKeyPair.NotFound"
ErrCodeInvalidNetworkInterfaceIDNotFound = "InvalidNetworkInterfaceID.NotFound"
ErrCodeInvalidParameter = "InvalidParameter"
ErrCodeInvalidParameterException = "InvalidParameterException"
ErrCodeInvalidParameterValue = "InvalidParameterValue"
ErrCodeInvalidPermissionDuplicate = "InvalidPermission.Duplicate"
ErrCodeInvalidPermissionMalformed = "InvalidPermission.Malformed"
ErrCodeInvalidPermissionNotFound = "InvalidPermission.NotFound"
ErrCodeInvalidPlacementGroupUnknown = "InvalidPlacementGroup.Unknown"
ErrCodeInvalidPrefixListIDNotFound = "InvalidPrefixListID.NotFound"
ErrCodeInvalidRouteNotFound = "InvalidRoute.NotFound"
ErrCodeInvalidRouteTableIDNotFound = "InvalidRouteTableID.NotFound"
ErrCodeInvalidRouteTableIdNotFound = "InvalidRouteTableId.NotFound"
ErrCodeInvalidSecurityGroupIDNotFound = "InvalidSecurityGroupID.NotFound"
ErrCodeInvalidSpotInstanceRequestIDNotFound = "InvalidSpotInstanceRequestID.NotFound"
ErrCodeInvalidSubnetCidrReservationIDNotFound = "InvalidSubnetCidrReservationID.NotFound"
ErrCodeInvalidSubnetIDNotFound = "InvalidSubnetID.NotFound"
ErrCodeInvalidSubnetIdNotFound = "InvalidSubnetId.NotFound"
ErrCodeInvalidTransitGatewayIDNotFound = "InvalidTransitGatewayID.NotFound"
ErrCodeInvalidVpcEndpointIdNotFound = "InvalidVpcEndpointId.NotFound"
ErrCodeInvalidVpcEndpointNotFound = "InvalidVpcEndpoint.NotFound"
ErrCodeInvalidVpcEndpointServiceIdNotFound = "InvalidVpcEndpointServiceId.NotFound"
ErrCodeInvalidVpcIDNotFound = "InvalidVpcID.NotFound"
ErrCodeInvalidVpcPeeringConnectionIDNotFound = "InvalidVpcPeeringConnectionID.NotFound"
ErrCodeInvalidVpnGatewayAttachmentNotFound = "InvalidVpnGatewayAttachment.NotFound"
ErrCodeInvalidVpnGatewayIDNotFound = "InvalidVpnGatewayID.NotFound"
)

func UnsuccessfulItemError(apiObject *ec2.UnsuccessfulItemError) error {
Expand Down
Loading

0 comments on commit 44e4255

Please sign in to comment.