From 6727ffa44d0f8b7a07a4f32666095188f65487a3 Mon Sep 17 00:00:00 2001 From: Matt Tse Date: Fri, 15 Mar 2024 09:46:55 -0400 Subject: [PATCH 1/7] resource/aws_vpn_connection: Remove transit_gateway_id dependency for ipv6 tunnel options --- .changelog/36075.txt | 3 +++ internal/service/ec2/vpnsite_connection.go | 4 ---- internal/service/ec2/vpnsite_connection_test.go | 5 ----- 3 files changed, 3 insertions(+), 9 deletions(-) create mode 100644 .changelog/36075.txt diff --git a/.changelog/36075.txt b/.changelog/36075.txt new file mode 100644 index 00000000000..374c387a5bd --- /dev/null +++ b/.changelog/36075.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_vpn_connection: Remove transit_gateway_id dependency for ipv6 tunnel options` +``` diff --git a/internal/service/ec2/vpnsite_connection.go b/internal/service/ec2/vpnsite_connection.go index dead903c3c7..65c57840fab 100644 --- a/internal/service/ec2/vpnsite_connection.go +++ b/internal/service/ec2/vpnsite_connection.go @@ -83,7 +83,6 @@ func ResourceVPNConnection() *schema.Resource { Optional: true, Computed: true, ValidateFunc: validation.IsCIDRNetwork(0, 128), - RequiredWith: []string{"transit_gateway_id"}, }, "outside_ip_address_type": { Type: schema.TypeString, @@ -102,7 +101,6 @@ func ResourceVPNConnection() *schema.Resource { Optional: true, Computed: true, ValidateFunc: validation.IsCIDRNetwork(0, 128), - RequiredWith: []string{"transit_gateway_id"}, }, "routes": { Type: schema.TypeSet, @@ -215,7 +213,6 @@ func ResourceVPNConnection() *schema.Resource { Computed: true, ForceNew: true, ValidateFunc: validVPNConnectionTunnelInsideIPv6CIDR(), - RequiredWith: []string{"transit_gateway_id"}, }, "tunnel1_log_options": { Type: schema.TypeList, @@ -432,7 +429,6 @@ func ResourceVPNConnection() *schema.Resource { Computed: true, ForceNew: true, ValidateFunc: validVPNConnectionTunnelInsideIPv6CIDR(), - RequiredWith: []string{"transit_gateway_id"}, }, "tunnel2_log_options": { Type: schema.TypeList, diff --git a/internal/service/ec2/vpnsite_connection_test.go b/internal/service/ec2/vpnsite_connection_test.go index 109cb929555..9e65d8249bb 100644 --- a/internal/service/ec2/vpnsite_connection_test.go +++ b/internal/service/ec2/vpnsite_connection_test.go @@ -2374,10 +2374,6 @@ resource "aws_vpn_connection" "test" { func testAccSiteVPNConnectionConfig_tunnel1InsideIPv6CIDR(rName string, rBgpAsn int, tunnel1InsideIpv6Cidr string, tunnel2InsideIpv6Cidr string) string { return fmt.Sprintf(` -resource "aws_ec2_transit_gateway" "test" { - description = %[1]q -} - resource "aws_customer_gateway" "test" { bgp_asn = %[2]d ip_address = "178.0.0.1" @@ -2390,7 +2386,6 @@ resource "aws_customer_gateway" "test" { resource "aws_vpn_connection" "test" { customer_gateway_id = aws_customer_gateway.test.id - transit_gateway_id = aws_ec2_transit_gateway.test.id tunnel_inside_ip_version = "ipv6" tunnel1_inside_ipv6_cidr = %[3]q tunnel2_inside_ipv6_cidr = %[4]q From 9ae13efef6b08ef36261c151fa25fa8a7d8f915b Mon Sep 17 00:00:00 2001 From: Matt Tse Date: Fri, 15 Mar 2024 09:47:13 -0400 Subject: [PATCH 2/7] Adds CHANGELOG entry --- .changelog/{36075.txt => 36390.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .changelog/{36075.txt => 36390.txt} (100%) diff --git a/.changelog/36075.txt b/.changelog/36390.txt similarity index 100% rename from .changelog/36075.txt rename to .changelog/36390.txt From 50fbf53e60b7debf5b13a0b005adf2be55543031 Mon Sep 17 00:00:00 2001 From: Matt Tse Date: Tue, 19 Mar 2024 09:47:57 -0400 Subject: [PATCH 3/7] update CHANGELOG name to match PR number --- .changelog/{36390.txt => 36405.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .changelog/{36390.txt => 36405.txt} (100%) diff --git a/.changelog/36390.txt b/.changelog/36405.txt similarity index 100% rename from .changelog/36390.txt rename to .changelog/36405.txt From a0ad1f32f7e5214b8982a48d9f5be373e34ccca5 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 20 Mar 2024 10:51:44 -0400 Subject: [PATCH 4/7] Tweak CHANGELOG entry. --- .changelog/36405.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changelog/36405.txt b/.changelog/36405.txt index 374c387a5bd..e4fc8a8645f 100644 --- a/.changelog/36405.txt +++ b/.changelog/36405.txt @@ -1,3 +1,3 @@ ```release-note:bug -resource/aws_vpn_connection: Remove transit_gateway_id dependency for ipv6 tunnel options` +resource/aws_vpn_connection: `local_ipv6_network_cidr`, `remote_ipv6_network_cidr`, `tunnel1_inside_ipv6_cidr`, and `tunnel2_inside_ipv6_cidr` no longer require `transit_gateway_id` to be specified ``` From a35ff75aae9e26df06f30590ad227af877f1903f Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 20 Mar 2024 10:57:46 -0400 Subject: [PATCH 5/7] ec2: Reduce visibility. --- internal/service/ec2/exports_test.go | 6 ++++++ internal/service/ec2/service_package_gen.go | 21 ++++++++++++------- internal/service/ec2/vpnsite_connection.go | 2 +- .../service/ec2/vpnsite_connection_route.go | 4 ++-- .../service/ec2/vpnsite_customer_gateway.go | 2 +- .../vpnsite_customer_gateway_data_source.go | 4 ++-- internal/service/ec2/vpnsite_gateway.go | 2 +- .../service/ec2/vpnsite_gateway_attachment.go | 4 ++-- .../ec2/vpnsite_gateway_data_source.go | 4 ++-- .../ec2/vpnsite_gateway_route_propagation.go | 4 ++-- 10 files changed, 32 insertions(+), 21 deletions(-) diff --git a/internal/service/ec2/exports_test.go b/internal/service/ec2/exports_test.go index 35865b96b31..0f5c1575f1c 100644 --- a/internal/service/ec2/exports_test.go +++ b/internal/service/ec2/exports_test.go @@ -5,6 +5,7 @@ package ec2 // Exports for use in tests only. var ( + ResourceCustomerGateway = resourceCustomerGateway ResourceDefaultNetworkACL = resourceDefaultNetworkACL ResourceDefaultRouteTable = resourceDefaultRouteTable ResourceEBSFastSnapshotRestore = newResourceEBSFastSnapshotRestore @@ -17,6 +18,11 @@ var ( ResourceSecurityGroupIngressRule = newResourceSecurityGroupIngressRule ResourceTag = resourceTag ResourceTransitGatewayPeeringAttachment = resourceTransitGatewayPeeringAttachment + ResourceVPNConnection = resourceVPNConnection + ResourceVPNConnectionRoute = resourceVPNConnectionRoute + ResourceVPNGateway = resourceVPNGateway + ResourceVPNGatewayAttachment = resourceVPNGatewayAttachment + ResourceVPNGatewayRoutePropagation = resourceVPNGatewayRoutePropagation CustomFiltersSchema = customFiltersSchema FindEBSFastSnapshotRestoreByID = findEBSFastSnapshotRestoreByID diff --git a/internal/service/ec2/service_package_gen.go b/internal/service/ec2/service_package_gen.go index cb01899e915..51dcd5889b3 100644 --- a/internal/service/ec2/service_package_gen.go +++ b/internal/service/ec2/service_package_gen.go @@ -77,8 +77,9 @@ func (p *servicePackage) SDKDataSources(ctx context.Context) []*types.ServicePac TypeName: "aws_availability_zones", }, { - Factory: DataSourceCustomerGateway, + Factory: dataSourceCustomerGateway, TypeName: "aws_customer_gateway", + Name: "Customer Gateway", }, { Factory: DataSourceEBSDefaultKMSKey, @@ -389,8 +390,9 @@ func (p *servicePackage) SDKDataSources(ctx context.Context) []*types.ServicePac TypeName: "aws_vpcs", }, { - Factory: DataSourceVPNGateway, + Factory: dataSourceVPNGateway, TypeName: "aws_vpn_gateway", + Name: "VPN Gateway", }, } } @@ -426,7 +428,7 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka TypeName: "aws_ami_launch_permission", }, { - Factory: ResourceCustomerGateway, + Factory: resourceCustomerGateway, TypeName: "aws_customer_gateway", Name: "Customer Gateway", Tags: &types.ServicePackageResourceTags{ @@ -1161,7 +1163,7 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka TypeName: "aws_vpc_peering_connection_options", }, { - Factory: ResourceVPNConnection, + Factory: resourceVPNConnection, TypeName: "aws_vpn_connection", Name: "VPN Connection", Tags: &types.ServicePackageResourceTags{ @@ -1169,11 +1171,12 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka }, }, { - Factory: ResourceVPNConnectionRoute, + Factory: resourceVPNConnectionRoute, TypeName: "aws_vpn_connection_route", + Name: "VPN Connection Route", }, { - Factory: ResourceVPNGateway, + Factory: resourceVPNGateway, TypeName: "aws_vpn_gateway", Name: "VPN Gateway", Tags: &types.ServicePackageResourceTags{ @@ -1181,12 +1184,14 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka }, }, { - Factory: ResourceVPNGatewayAttachment, + Factory: resourceVPNGatewayAttachment, TypeName: "aws_vpn_gateway_attachment", + Name: "VPN Gateway Attachment", }, { - Factory: ResourceVPNGatewayRoutePropagation, + Factory: resourceVPNGatewayRoutePropagation, TypeName: "aws_vpn_gateway_route_propagation", + Name: "VPN Gateway Route Propagation", }, } } diff --git a/internal/service/ec2/vpnsite_connection.go b/internal/service/ec2/vpnsite_connection.go index 65c57840fab..7b660111e51 100644 --- a/internal/service/ec2/vpnsite_connection.go +++ b/internal/service/ec2/vpnsite_connection.go @@ -32,7 +32,7 @@ import ( // @SDKResource("aws_vpn_connection", name="VPN Connection") // @Tags(identifierAttribute="id") -func ResourceVPNConnection() *schema.Resource { +func resourceVPNConnection() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceVPNConnectionCreate, ReadWithoutTimeout: resourceVPNConnectionRead, diff --git a/internal/service/ec2/vpnsite_connection_route.go b/internal/service/ec2/vpnsite_connection_route.go index a7801a118d3..557bcc045a2 100644 --- a/internal/service/ec2/vpnsite_connection_route.go +++ b/internal/service/ec2/vpnsite_connection_route.go @@ -19,8 +19,8 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/tfresource" ) -// @SDKResource("aws_vpn_connection_route") -func ResourceVPNConnectionRoute() *schema.Resource { +// @SDKResource("aws_vpn_connection_route", name="VPN Connection Route") +func resourceVPNConnectionRoute() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceVPNConnectionRouteCreate, ReadWithoutTimeout: resourceVPNConnectionRouteRead, diff --git a/internal/service/ec2/vpnsite_customer_gateway.go b/internal/service/ec2/vpnsite_customer_gateway.go index c4736495c23..74ea7d0ee22 100644 --- a/internal/service/ec2/vpnsite_customer_gateway.go +++ b/internal/service/ec2/vpnsite_customer_gateway.go @@ -26,7 +26,7 @@ import ( // @SDKResource("aws_customer_gateway", name="Customer Gateway") // @Tags(identifierAttribute="id") -func ResourceCustomerGateway() *schema.Resource { +func resourceCustomerGateway() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceCustomerGatewayCreate, ReadWithoutTimeout: resourceCustomerGatewayRead, diff --git a/internal/service/ec2/vpnsite_customer_gateway_data_source.go b/internal/service/ec2/vpnsite_customer_gateway_data_source.go index 491d068fc48..02f4c1824e6 100644 --- a/internal/service/ec2/vpnsite_customer_gateway_data_source.go +++ b/internal/service/ec2/vpnsite_customer_gateway_data_source.go @@ -20,8 +20,8 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/tfresource" ) -// @SDKDataSource("aws_customer_gateway") -func DataSourceCustomerGateway() *schema.Resource { +// @SDKDataSource("aws_customer_gateway", name="Customer Gateway") +func dataSourceCustomerGateway() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceCustomerGatewayRead, diff --git a/internal/service/ec2/vpnsite_gateway.go b/internal/service/ec2/vpnsite_gateway.go index 0ad3c193a33..a427f0415eb 100644 --- a/internal/service/ec2/vpnsite_gateway.go +++ b/internal/service/ec2/vpnsite_gateway.go @@ -25,7 +25,7 @@ import ( // @SDKResource("aws_vpn_gateway", name="VPN Gateway") // @Tags(identifierAttribute="id") -func ResourceVPNGateway() *schema.Resource { +func resourceVPNGateway() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceVPNGatewayCreate, ReadWithoutTimeout: resourceVPNGatewayRead, diff --git a/internal/service/ec2/vpnsite_gateway_attachment.go b/internal/service/ec2/vpnsite_gateway_attachment.go index 2e37b32d4ae..479b5aa5be2 100644 --- a/internal/service/ec2/vpnsite_gateway_attachment.go +++ b/internal/service/ec2/vpnsite_gateway_attachment.go @@ -17,8 +17,8 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/tfresource" ) -// @SDKResource("aws_vpn_gateway_attachment") -func ResourceVPNGatewayAttachment() *schema.Resource { +// @SDKResource("aws_vpn_gateway_attachment", name="VPN Gateway Attachment") +func resourceVPNGatewayAttachment() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceVPNGatewayAttachmentCreate, ReadWithoutTimeout: resourceVPNGatewayAttachmentRead, diff --git a/internal/service/ec2/vpnsite_gateway_data_source.go b/internal/service/ec2/vpnsite_gateway_data_source.go index 75519f9c28f..ef5c4155910 100644 --- a/internal/service/ec2/vpnsite_gateway_data_source.go +++ b/internal/service/ec2/vpnsite_gateway_data_source.go @@ -20,8 +20,8 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/tfresource" ) -// @SDKDataSource("aws_vpn_gateway") -func DataSourceVPNGateway() *schema.Resource { +// @SDKDataSource("aws_vpn_gateway", name="VPN Gateway") +func dataSourceVPNGateway() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceVPNGatewayRead, diff --git a/internal/service/ec2/vpnsite_gateway_route_propagation.go b/internal/service/ec2/vpnsite_gateway_route_propagation.go index 644ec71f2dc..72eb40bd180 100644 --- a/internal/service/ec2/vpnsite_gateway_route_propagation.go +++ b/internal/service/ec2/vpnsite_gateway_route_propagation.go @@ -16,8 +16,8 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/tfresource" ) -// @SDKResource("aws_vpn_gateway_route_propagation") -func ResourceVPNGatewayRoutePropagation() *schema.Resource { +// @SDKResource("aws_vpn_gateway_route_propagation", name="VPN Gateway Route Propagation") +func resourceVPNGatewayRoutePropagation() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceVPNGatewayRoutePropagationEnable, ReadWithoutTimeout: resourceVPNGatewayRoutePropagationRead, From 5f636d842636a83a91ab133df60e7b0262a02a8e Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 20 Mar 2024 11:06:19 -0400 Subject: [PATCH 6/7] Fix sweeper compilation errors. --- internal/service/ec2/sweep.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/ec2/sweep.go b/internal/service/ec2/sweep.go index c13b3d24a3e..03843547fb7 100644 --- a/internal/service/ec2/sweep.go +++ b/internal/service/ec2/sweep.go @@ -2575,7 +2575,7 @@ func sweepVPNConnections(region string) error { continue } - r := ResourceVPNConnection() + r := resourceVPNConnection() d := r.Data(nil) d.SetId(aws.StringValue(v.VpnConnectionId)) @@ -2617,7 +2617,7 @@ func sweepVPNGateways(region string) error { continue } - r := ResourceVPNGateway() + r := resourceVPNGateway() d := r.Data(nil) d.SetId(aws.StringValue(v.VpnGatewayId)) @@ -2667,7 +2667,7 @@ func sweepCustomerGateways(region string) error { continue } - r := ResourceCustomerGateway() + r := resourceCustomerGateway() d := r.Data(nil) d.SetId(aws.StringValue(v.CustomerGatewayId)) From 85032a54d0c2d1b74848f98a2b9f2d8212677e5f Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 20 Mar 2024 11:08:11 -0400 Subject: [PATCH 7/7] Remove 'testAccCustomerGatewayAssociation_Disappears_customerGateway'. --- .../customer_gateway_association_test.go | 32 ++----------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/internal/service/networkmanager/customer_gateway_association_test.go b/internal/service/networkmanager/customer_gateway_association_test.go index 8d0ac82c529..3fbdc1bf532 100644 --- a/internal/service/networkmanager/customer_gateway_association_test.go +++ b/internal/service/networkmanager/customer_gateway_association_test.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" - tfec2 "github.com/hashicorp/terraform-provider-aws/internal/service/ec2" tfnetworkmanager "github.com/hashicorp/terraform-provider-aws/internal/service/networkmanager" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/names" @@ -23,9 +22,8 @@ func TestAccNetworkManagerCustomerGatewayAssociation_serial(t *testing.T) { t.Parallel() testCases := map[string]func(t *testing.T){ - "basic": testAccCustomerGatewayAssociation_basic, - "disappears": testAccCustomerGatewayAssociation_disappears, - "disappears_CustomerGateway": testAccCustomerGatewayAssociation_Disappears_customerGateway, + "basic": testAccCustomerGatewayAssociation_basic, + "disappears": testAccCustomerGatewayAssociation_disappears, } acctest.RunSerialTests1Level(t, testCases, 0) @@ -80,32 +78,6 @@ func testAccCustomerGatewayAssociation_disappears(t *testing.T) { }) } -func testAccCustomerGatewayAssociation_Disappears_customerGateway(t *testing.T) { - ctx := acctest.Context(t) - resourceName := "aws_networkmanager_customer_gateway_association.test" - vpnConnectionResourceName := "aws_vpn_connection.test" - customerGatewayResourceName := "aws_customer_gateway.test" - rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t) }, - ErrorCheck: acctest.ErrorCheck(t, names.NetworkManagerServiceID), - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - CheckDestroy: testAccCheckCustomerGatewayAssociationDestroy(ctx), - Steps: []resource.TestStep{ - { - Config: testAccCustomerGatewayAssociationConfig_basic(rName), - Check: resource.ComposeTestCheckFunc( - testAccCheckCustomerGatewayAssociationExists(ctx, resourceName), - acctest.CheckResourceDisappears(ctx, acctest.Provider, tfec2.ResourceVPNConnection(), vpnConnectionResourceName), - acctest.CheckResourceDisappears(ctx, acctest.Provider, tfec2.ResourceCustomerGateway(), customerGatewayResourceName), - ), - ExpectNonEmptyPlan: true, - }, - }, - }) -} - func testAccCheckCustomerGatewayAssociationDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { conn := acctest.Provider.Meta().(*conns.AWSClient).NetworkManagerConn(ctx)