From 3776f518fa3942e366f823d1c341ffbc622dad42 Mon Sep 17 00:00:00 2001 From: Giulio Micheloni Date: Mon, 4 Apr 2022 23:45:38 +0100 Subject: [PATCH 01/12] resource/aws_route: SetId before WaitRouteReady When the route's wait-for-creation operation times out, its state is leaked as `d.SetId(...)` is called after the `WaitRouteReady(...)`. So, the next time the configuration is applied, the Terraform engine tries to create the same route again, getting duplication error from AWS. Call `d.SetId(...)` before `WaitRouteReady(...)`. Fixes: #23827 --- internal/service/ec2/route.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/ec2/route.go b/internal/service/ec2/route.go index da26207275b..6354f40cd5d 100644 --- a/internal/service/ec2/route.go +++ b/internal/service/ec2/route.go @@ -239,14 +239,14 @@ func resourceRouteCreate(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("error creating Route in Route Table (%s) with destination (%s): %w", routeTableID, destination, err) } + d.SetId(RouteCreateID(routeTableID, destination)) + _, err = WaitRouteReady(conn, routeFinder, routeTableID, destination, d.Timeout(schema.TimeoutCreate)) if err != nil { return fmt.Errorf("error waiting for Route in Route Table (%s) with destination (%s) to become available: %w", routeTableID, destination, err) } - d.SetId(RouteCreateID(routeTableID, destination)) - return resourceRouteRead(d, meta) } From b49ba8222175a6cc966b527ca2cc0bc37a14b88d Mon Sep 17 00:00:00 2001 From: Giulio Micheloni Date: Mon, 4 Apr 2022 23:45:38 +0100 Subject: [PATCH 02/12] resource/aws_route: SetId before WaitRouteReady Issue: When the route's wait-for-creation operation times out, its state is leaked as `d.SetId(...)` is called after the `WaitRouteReady(...)`. So, the next time the configuration is applied, the Terraform engine tries to create the same route again, getting duplication error from AWS. Fix: Call `d.SetId(...)` before `WaitRouteReady(...)`. Fixes: #23827 --- internal/service/ec2/route.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/ec2/route.go b/internal/service/ec2/route.go index da26207275b..6354f40cd5d 100644 --- a/internal/service/ec2/route.go +++ b/internal/service/ec2/route.go @@ -239,14 +239,14 @@ func resourceRouteCreate(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("error creating Route in Route Table (%s) with destination (%s): %w", routeTableID, destination, err) } + d.SetId(RouteCreateID(routeTableID, destination)) + _, err = WaitRouteReady(conn, routeFinder, routeTableID, destination, d.Timeout(schema.TimeoutCreate)) if err != nil { return fmt.Errorf("error waiting for Route in Route Table (%s) with destination (%s) to become available: %w", routeTableID, destination, err) } - d.SetId(RouteCreateID(routeTableID, destination)) - return resourceRouteRead(d, meta) } From e8eca40f78d3534ccf0fe80dad8001b33fc28716 Mon Sep 17 00:00:00 2001 From: Giulio Micheloni Date: Tue, 5 Apr 2022 00:18:02 +0100 Subject: [PATCH 03/12] Changelog file --- .changelog/24024.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/24024.txt diff --git a/.changelog/24024.txt b/.changelog/24024.txt new file mode 100644 index 00000000000..920a1791efa --- /dev/null +++ b/.changelog/24024.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_route: Fix state leakage in case of wait-for-creation times out +``` From fb702cd227862422a08bc85179e6c0d86f3a205a Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 5 Apr 2022 08:33:49 -0400 Subject: [PATCH 04/12] Tweak CHANGELOG entry. --- .changelog/24024.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changelog/24024.txt b/.changelog/24024.txt index 920a1791efa..6f690a3db74 100644 --- a/.changelog/24024.txt +++ b/.changelog/24024.txt @@ -1,3 +1,3 @@ ```release-note:bug -resource/aws_route: Fix state leakage in case of wait-for-creation times out +resource/aws_route: Ensure that resource ID is set in case of wait-for-creation time out ``` From bda73c9c0e209ad00134d0f64ba78c0ca9f59246 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 5 Apr 2022 08:45:35 -0400 Subject: [PATCH 05/12] r/aws_route: Add 'core_network_arn' argument. --- .changelog/24024.txt | 4 +++ internal/service/ec2/route.go | 11 +++++++ internal/service/ec2/route_test.go | 47 ++++++++++++++++++++++++++++++ website/docs/r/route.html.markdown | 1 + 4 files changed, 63 insertions(+) diff --git a/.changelog/24024.txt b/.changelog/24024.txt index 6f690a3db74..9e302d1d4d5 100644 --- a/.changelog/24024.txt +++ b/.changelog/24024.txt @@ -1,3 +1,7 @@ ```release-note:bug resource/aws_route: Ensure that resource ID is set in case of wait-for-creation time out ``` + +```release-note:enhancement +resource/aws_route: Add `core_network_arn` argument +``` \ No newline at end of file diff --git a/internal/service/ec2/route.go b/internal/service/ec2/route.go index 6354f40cd5d..73c1cc9d938 100644 --- a/internal/service/ec2/route.go +++ b/internal/service/ec2/route.go @@ -23,6 +23,7 @@ var routeValidDestinations = []string{ var routeValidTargets = []string{ "carrier_gateway_id", + "core_network_arn", "egress_only_gateway_id", "gateway_id", "instance_id", @@ -91,6 +92,11 @@ func ResourceRoute() *schema.Resource { ExactlyOneOf: routeValidTargets, ConflictsWith: []string{"destination_ipv6_cidr_block"}, // IPv4 destinations only. }, + "core_network_arn": { + Type: schema.TypeString, + Optional: true, + ExactlyOneOf: routeValidTargets, + }, "egress_only_gateway_id": { Type: schema.TypeString, Optional: true, @@ -203,6 +209,8 @@ func resourceRouteCreate(d *schema.ResourceData, meta interface{}) error { switch target := aws.String(target); targetAttributeKey { case "carrier_gateway_id": input.CarrierGatewayId = target + case "core_network_arn": + input.CoreNetworkArn = target case "egress_only_gateway_id": input.EgressOnlyInternetGatewayId = target case "gateway_id": @@ -287,6 +295,7 @@ func resourceRouteRead(d *schema.ResourceData, meta interface{}) error { } d.Set("carrier_gateway_id", route.CarrierGatewayId) + d.Set("nat_gatcore_network_arneway_id", route.CoreNetworkArn) d.Set("destination_cidr_block", route.DestinationCidrBlock) d.Set("destination_ipv6_cidr_block", route.DestinationIpv6CidrBlock) d.Set("destination_prefix_list_id", route.DestinationPrefixListId) @@ -351,6 +360,8 @@ func resourceRouteUpdate(d *schema.ResourceData, meta interface{}) error { switch target := aws.String(target); targetAttributeKey { case "carrier_gateway_id": input.CarrierGatewayId = target + case "core_network_arn": + input.CoreNetworkArn = target case "egress_only_gateway_id": input.EgressOnlyInternetGatewayId = target case "gateway_id": diff --git a/internal/service/ec2/route_test.go b/internal/service/ec2/route_test.go index 50c5c78c355..dcc51e0c616 100644 --- a/internal/service/ec2/route_test.go +++ b/internal/service/ec2/route_test.go @@ -38,6 +38,7 @@ func TestAccEC2Route_basic(t *testing.T) { testAccCheckRouteTableNumberOfRoutes(&routeTable, 2), testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -132,6 +133,7 @@ func TestAccEC2Route_ipv6ToEgressOnlyInternetGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -182,6 +184,7 @@ func TestAccEC2Route_ipv6ToInternetGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -227,6 +230,7 @@ func TestAccEC2Route_ipv6ToInstance(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -272,6 +276,7 @@ func TestAccEC2Route_IPv6ToNetworkInterface_unattached(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -317,6 +322,7 @@ func TestAccEC2Route_ipv6ToVPCPeeringConnection(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -362,6 +368,7 @@ func TestAccEC2Route_ipv6ToVPNGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -407,6 +414,7 @@ func TestAccEC2Route_ipv4ToVPNGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -452,6 +460,7 @@ func TestAccEC2Route_ipv4ToInstance(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -497,6 +506,7 @@ func TestAccEC2Route_IPv4ToNetworkInterface_unattached(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -543,6 +553,7 @@ func TestAccEC2Route_IPv4ToNetworkInterface_attached(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -590,6 +601,7 @@ func TestAccEC2Route_IPv4ToNetworkInterface_twoAttachments(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -612,6 +624,7 @@ func TestAccEC2Route_IPv4ToNetworkInterface_twoAttachments(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -657,6 +670,7 @@ func TestAccEC2Route_ipv4ToVPCPeeringConnection(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -702,6 +716,7 @@ func TestAccEC2Route_ipv4ToNatGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -747,6 +762,7 @@ func TestAccEC2Route_ipv6ToNatGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -827,6 +843,7 @@ func TestAccEC2Route_ipv4ToTransitGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -876,6 +893,7 @@ func TestAccEC2Route_ipv6ToTransitGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -921,6 +939,7 @@ func TestAccEC2Route_ipv4ToCarrierGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttrPair(resourceName, "carrier_gateway_id", cgwResourceName, "id"), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -966,6 +985,7 @@ func TestAccEC2Route_ipv4ToLocalGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1011,6 +1031,7 @@ func TestAccEC2Route_ipv6ToLocalGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1106,6 +1127,7 @@ func TestAccEC2Route_IPv4Update_target(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1128,6 +1150,7 @@ func TestAccEC2Route_IPv4Update_target(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1150,6 +1173,7 @@ func TestAccEC2Route_IPv4Update_target(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1172,6 +1196,7 @@ func TestAccEC2Route_IPv4Update_target(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1194,6 +1219,7 @@ func TestAccEC2Route_IPv4Update_target(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1217,6 +1243,7 @@ func TestAccEC2Route_IPv4Update_target(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1239,6 +1266,7 @@ func TestAccEC2Route_IPv4Update_target(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1261,6 +1289,7 @@ func TestAccEC2Route_IPv4Update_target(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1315,6 +1344,7 @@ func TestAccEC2Route_IPv6Update_target(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1337,6 +1367,7 @@ func TestAccEC2Route_IPv6Update_target(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1359,6 +1390,7 @@ func TestAccEC2Route_IPv6Update_target(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1381,6 +1413,7 @@ func TestAccEC2Route_IPv6Update_target(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1403,6 +1436,7 @@ func TestAccEC2Route_IPv6Update_target(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1425,6 +1459,7 @@ func TestAccEC2Route_IPv6Update_target(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1474,6 +1509,7 @@ func TestAccEC2Route_ipv4ToVPCEndpoint(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", destinationCidr), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""), @@ -1559,6 +1595,7 @@ func TestAccEC2Route_prefixListToInternetGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttrPair(resourceName, "destination_prefix_list_id", plResourceName, "id"), @@ -1604,6 +1641,7 @@ func TestAccEC2Route_prefixListToVPNGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttrPair(resourceName, "destination_prefix_list_id", plResourceName, "id"), @@ -1649,6 +1687,7 @@ func TestAccEC2Route_prefixListToInstance(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttrPair(resourceName, "destination_prefix_list_id", plResourceName, "id"), @@ -1694,6 +1733,7 @@ func TestAccEC2Route_PrefixListToNetworkInterface_unattached(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttrPair(resourceName, "destination_prefix_list_id", plResourceName, "id"), @@ -1740,6 +1780,7 @@ func TestAccEC2Route_PrefixListToNetworkInterface_attached(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttrPair(resourceName, "destination_prefix_list_id", plResourceName, "id"), @@ -1785,6 +1826,7 @@ func TestAccEC2Route_prefixListToVPCPeeringConnection(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttrPair(resourceName, "destination_prefix_list_id", plResourceName, "id"), @@ -1830,6 +1872,7 @@ func TestAccEC2Route_prefixListToNatGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttrPair(resourceName, "destination_prefix_list_id", plResourceName, "id"), @@ -1879,6 +1922,7 @@ func TestAccEC2Route_prefixListToTransitGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttrPair(resourceName, "destination_prefix_list_id", plResourceName, "id"), @@ -1928,6 +1972,7 @@ func TestAccEC2Route_prefixListToCarrierGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttrPair(resourceName, "carrier_gateway_id", cgwResourceName, "id"), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttrPair(resourceName, "destination_prefix_list_id", plResourceName, "id"), @@ -1977,6 +2022,7 @@ func TestAccEC2Route_prefixListToLocalGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttrPair(resourceName, "destination_prefix_list_id", plResourceName, "id"), @@ -2022,6 +2068,7 @@ func TestAccEC2Route_prefixListToEgressOnlyInternetGateway(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRouteExists(resourceName, &route), resource.TestCheckResourceAttr(resourceName, "carrier_gateway_id", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""), resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", ""), resource.TestCheckResourceAttrPair(resourceName, "destination_prefix_list_id", plResourceName, "id"), diff --git a/website/docs/r/route.html.markdown b/website/docs/r/route.html.markdown index 12702130c5a..0f5295b19ee 100644 --- a/website/docs/r/route.html.markdown +++ b/website/docs/r/route.html.markdown @@ -59,6 +59,7 @@ One of the following destination arguments must be supplied: One of the following target arguments must be supplied: * `carrier_gateway_id` - (Optional) Identifier of a carrier gateway. This attribute can only be used when the VPC contains a subnet which is associated with a Wavelength Zone. +* `core_network_arn` - (Optional) The Amazon Resource Name (ARN) of a core network. * `egress_only_gateway_id` - (Optional) Identifier of a VPC Egress Only Internet Gateway. * `gateway_id` - (Optional) Identifier of a VPC internet gateway or a virtual private gateway. * `instance_id` - (Optional, **Deprecated** use `network_interface_id` instead) Identifier of an EC2 instance. From 2fe6dfda15eefc332d2e37aa350c9599438818f1 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 5 Apr 2022 08:49:36 -0400 Subject: [PATCH 06/12] d/aws_route: Add 'core_network_arn' argument. --- .changelog/24024.txt | 4 ++++ internal/service/ec2/route_data_source.go | 11 ++++++++++- website/docs/d/route.html.markdown | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.changelog/24024.txt b/.changelog/24024.txt index 9e302d1d4d5..e6aa3331fed 100644 --- a/.changelog/24024.txt +++ b/.changelog/24024.txt @@ -4,4 +4,8 @@ resource/aws_route: Ensure that resource ID is set in case of wait-for-creation ```release-note:enhancement resource/aws_route: Add `core_network_arn` argument +``` + +```release-note:enhancement +data-source/aws_route: Add `core_network_arn` argument ``` \ No newline at end of file diff --git a/internal/service/ec2/route_data_source.go b/internal/service/ec2/route_data_source.go index 3f70b064d8b..1e37d02220a 100644 --- a/internal/service/ec2/route_data_source.go +++ b/internal/service/ec2/route_data_source.go @@ -33,7 +33,6 @@ func DataSourceRoute() *schema.Resource { Optional: true, Computed: true, }, - "destination_prefix_list_id": { Type: schema.TypeString, Optional: true, @@ -48,6 +47,11 @@ func DataSourceRoute() *schema.Resource { Optional: true, Computed: true, }, + "core_network_arn": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, "egress_only_gateway_id": { Type: schema.TypeString, Optional: true, @@ -132,6 +136,10 @@ func dataSourceRouteRead(d *schema.ResourceData, meta interface{}) error { continue } + if v, ok := d.GetOk("core_network_arn"); ok && aws.StringValue(r.CoreNetworkArn) != v.(string) { + continue + } + if v, ok := d.GetOk("egress_only_gateway_id"); ok && aws.StringValue(r.EgressOnlyInternetGatewayId) != v.(string) { continue } @@ -186,6 +194,7 @@ func dataSourceRouteRead(d *schema.ResourceData, meta interface{}) error { } d.Set("carrier_gateway_id", route.CarrierGatewayId) + d.Set("core_network_arn", route.CoreNetworkArn) d.Set("destination_cidr_block", route.DestinationCidrBlock) d.Set("destination_ipv6_cidr_block", route.DestinationIpv6CidrBlock) d.Set("destination_prefix_list_id", route.DestinationPrefixListId) diff --git a/website/docs/d/route.html.markdown b/website/docs/d/route.html.markdown index 38d0c4fdb3f..0babfd7072e 100644 --- a/website/docs/d/route.html.markdown +++ b/website/docs/d/route.html.markdown @@ -44,6 +44,7 @@ The following arguments are required: The following arguments are optional: * `carrier_gateway_id` - (Optional) EC2 Carrier Gateway ID of the Route belonging to the Route Table. +* `core_network_arn` - (Optional) Core network ARN of the Route belonging to the Route Table. * `destination_cidr_block` - (Optional) CIDR block of the Route belonging to the Route Table. * `destination_ipv6_cidr_block` - (Optional) IPv6 CIDR block of the Route belonging to the Route Table. * `destination_prefix_list_id` - (Optional) The ID of a [managed prefix list](ec2_managed_prefix_list.html) destination of the Route belonging to the Route Table. From d163536b3a8d3fd278d39b7488e3bbc308443428 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 5 Apr 2022 08:55:56 -0400 Subject: [PATCH 07/12] r/aws_route_table: Add 'core_network_arn' argument to 'route' configuration block. --- .changelog/24024.txt | 4 ++++ internal/service/ec2/route_table.go | 21 +++++++++++++++++++++ website/docs/r/route_table.html.markdown | 1 + 3 files changed, 26 insertions(+) diff --git a/.changelog/24024.txt b/.changelog/24024.txt index e6aa3331fed..b9e2fe05701 100644 --- a/.changelog/24024.txt +++ b/.changelog/24024.txt @@ -8,4 +8,8 @@ resource/aws_route: Add `core_network_arn` argument ```release-note:enhancement data-source/aws_route: Add `core_network_arn` argument +``` + +```release-note:enhancement +resource/aws_route_table: Add `core_network_arn` argument to the `route` configuration block ``` \ No newline at end of file diff --git a/internal/service/ec2/route_table.go b/internal/service/ec2/route_table.go index 3e99a0ff942..c6abff4cdda 100644 --- a/internal/service/ec2/route_table.go +++ b/internal/service/ec2/route_table.go @@ -27,6 +27,7 @@ var routeTableValidDestinations = []string{ var routeTableValidTargets = []string{ "carrier_gateway_id", + "core_network_arn", "egress_only_gateway_id", "gateway_id", "instance_id", @@ -105,6 +106,10 @@ func ResourceRouteTable() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "core_network_arn": { + Type: schema.TypeString, + Optional: true, + }, "egress_only_gateway_id": { Type: schema.TypeString, Optional: true, @@ -429,6 +434,10 @@ func resourceRouteTableHash(v interface{}) int { buf.WriteString(fmt.Sprintf("%s-", v.(string))) } + if v, ok := m["core_network_arn"]; ok { + buf.WriteString(fmt.Sprintf("%s-", v.(string))) + } + if v, ok := m["egress_only_gateway_id"]; ok { buf.WriteString(fmt.Sprintf("%s-", v.(string))) } @@ -681,6 +690,10 @@ func expandEc2CreateRouteInput(tfMap map[string]interface{}) *ec2.CreateRouteInp apiObject.CarrierGatewayId = aws.String(v) } + if v, ok := tfMap["core_network_arn"].(string); ok && v != "" { + apiObject.CoreNetworkArn = aws.String(v) + } + if v, ok := tfMap["egress_only_gateway_id"].(string); ok && v != "" { apiObject.EgressOnlyInternetGatewayId = aws.String(v) } @@ -743,6 +756,10 @@ func expandEc2ReplaceRouteInput(tfMap map[string]interface{}) *ec2.ReplaceRouteI apiObject.CarrierGatewayId = aws.String(v) } + if v, ok := tfMap["core_network_arn"].(string); ok && v != "" { + apiObject.CarrierGatewayId = aws.String(v) + } + if v, ok := tfMap["egress_only_gateway_id"].(string); ok && v != "" { apiObject.EgressOnlyInternetGatewayId = aws.String(v) } @@ -805,6 +822,10 @@ func flattenEc2Route(apiObject *ec2.Route) map[string]interface{} { tfMap["carrier_gateway_id"] = aws.StringValue(v) } + if v := apiObject.CoreNetworkArn; v != nil { + tfMap["core_network_arn"] = aws.StringValue(v) + } + if v := apiObject.EgressOnlyInternetGatewayId; v != nil { tfMap["egress_only_gateway_id"] = aws.StringValue(v) } diff --git a/website/docs/r/route_table.html.markdown b/website/docs/r/route_table.html.markdown index 2ad02c9968e..ee03b830ce0 100644 --- a/website/docs/r/route_table.html.markdown +++ b/website/docs/r/route_table.html.markdown @@ -88,6 +88,7 @@ One of the following destination arguments must be supplied: One of the following target arguments must be supplied: * `carrier_gateway_id` - (Optional) Identifier of a carrier gateway. This attribute can only be used when the VPC contains a subnet which is associated with a Wavelength Zone. +* `core_network_arn` - (Optional) The Amazon Resource Name (ARN) of a core network. * `egress_only_gateway_id` - (Optional) Identifier of a VPC Egress Only Internet Gateway. * `gateway_id` - (Optional) Identifier of a VPC internet gateway or a virtual private gateway. * `instance_id` - (Optional, **Deprecated** use `network_interface_id` instead) Identifier of an EC2 instance. From 787e162d1d0e4eac542990148cb67053ebfc51b6 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 5 Apr 2022 09:00:38 -0400 Subject: [PATCH 08/12] d/aws_route_table: Add 'routes.core_network_arn' attribute. --- .changelog/24024.txt | 4 ++++ internal/service/ec2/route_table_data_source.go | 8 ++++++++ website/docs/d/route_table.html.markdown | 1 + 3 files changed, 13 insertions(+) diff --git a/.changelog/24024.txt b/.changelog/24024.txt index b9e2fe05701..20f8bbb7224 100644 --- a/.changelog/24024.txt +++ b/.changelog/24024.txt @@ -12,4 +12,8 @@ data-source/aws_route: Add `core_network_arn` argument ```release-note:enhancement resource/aws_route_table: Add `core_network_arn` argument to the `route` configuration block +``` + +```release-note:enhancement +data-source/aws_route_table: Add 'routes.core_network_arn' attribute' ``` \ No newline at end of file diff --git a/internal/service/ec2/route_table_data_source.go b/internal/service/ec2/route_table_data_source.go index 7a0be6d5dd5..90fd8d0b123 100644 --- a/internal/service/ec2/route_table_data_source.go +++ b/internal/service/ec2/route_table_data_source.go @@ -71,6 +71,11 @@ func DataSourceRouteTable() *schema.Resource { Computed: true, }, + "core_network_arn": { + Type: schema.TypeString, + Computed: true, + }, + "egress_only_gateway_id": { Type: schema.TypeString, Computed: true, @@ -285,6 +290,9 @@ func dataSourceRoutesRead(conn *ec2.EC2, ec2Routes []*ec2.Route) []map[string]in if r.CarrierGatewayId != nil { m["carrier_gateway_id"] = *r.CarrierGatewayId } + if r.CoreNetworkArn != nil { + m["core_network_arn"] = *r.CoreNetworkArn + } if r.EgressOnlyInternetGatewayId != nil { m["egress_only_gateway_id"] = *r.EgressOnlyInternetGatewayId } diff --git a/website/docs/d/route_table.html.markdown b/website/docs/d/route_table.html.markdown index 0f03e35cd4d..1072cc22cc8 100644 --- a/website/docs/d/route_table.html.markdown +++ b/website/docs/d/route_table.html.markdown @@ -74,6 +74,7 @@ For destinations: For targets: * `carrier_gateway_id` - ID of the Carrier Gateway. +* `core_network_arn` - ARN of the core network. * `egress_only_gateway_id` - ID of the Egress Only Internet Gateway. * `gateway_id` - Internet Gateway ID. * `instance_id` - EC2 instance ID. From 94119296431eaa97c8de2c4bdd4e4c1f53eb8dc9 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 5 Apr 2022 09:04:18 -0400 Subject: [PATCH 09/12] r/aws_default_route_table: Add 'core_network_arn' argument to 'route' configuration block. --- .changelog/24024.txt | 4 ++++ internal/service/ec2/default_route_table.go | 4 ++++ website/docs/r/default_route_table.html.markdown | 1 + 3 files changed, 9 insertions(+) diff --git a/.changelog/24024.txt b/.changelog/24024.txt index 20f8bbb7224..b69c4c1841b 100644 --- a/.changelog/24024.txt +++ b/.changelog/24024.txt @@ -16,4 +16,8 @@ resource/aws_route_table: Add `core_network_arn` argument to the `route` configu ```release-note:enhancement data-source/aws_route_table: Add 'routes.core_network_arn' attribute' +``` + +```release-note:enhancement +resource/aws_default_route_table: Add `core_network_arn` argument to the `route` configuration block ``` \ No newline at end of file diff --git a/internal/service/ec2/default_route_table.go b/internal/service/ec2/default_route_table.go index 7becd9bd7b2..8fde169f64a 100644 --- a/internal/service/ec2/default_route_table.go +++ b/internal/service/ec2/default_route_table.go @@ -88,6 +88,10 @@ func ResourceDefaultRouteTable() *schema.Resource { // These target attributes are a subset of the aws_route_table resource's target attributes // as there are some targets that are not allowed in the default route table for a VPC. // + "core_network_arn": { + Type: schema.TypeString, + Optional: true, + }, "egress_only_gateway_id": { Type: schema.TypeString, Optional: true, diff --git a/website/docs/r/default_route_table.html.markdown b/website/docs/r/default_route_table.html.markdown index 7482fadd0d4..77e951fa6b6 100644 --- a/website/docs/r/default_route_table.html.markdown +++ b/website/docs/r/default_route_table.html.markdown @@ -76,6 +76,7 @@ One of the following destination arguments must be supplied: One of the following target arguments must be supplied: +* `core_network_arn` - (Optional) The Amazon Resource Name (ARN) of a core network. * `egress_only_gateway_id` - (Optional) Identifier of a VPC Egress Only Internet Gateway. * `gateway_id` - (Optional) Identifier of a VPC internet gateway or a virtual private gateway. * `instance_id` - (Optional) Identifier of an EC2 instance. From 56710c95159aaf091e0cd9e5b89a748e5687f804 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 5 Apr 2022 09:13:23 -0400 Subject: [PATCH 10/12] r/aws_vpn_connection: Add 'core_network_arn' and 'core_network_attachment_arn' attributes. --- .changelog/24024.txt | 6 +++++- internal/service/ec2/vpn_connection.go | 10 ++++++++++ internal/service/ec2/vpn_connection_test.go | 2 ++ website/docs/r/vpn_connection.html.markdown | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.changelog/24024.txt b/.changelog/24024.txt index b69c4c1841b..00a4c658261 100644 --- a/.changelog/24024.txt +++ b/.changelog/24024.txt @@ -20,4 +20,8 @@ data-source/aws_route_table: Add 'routes.core_network_arn' attribute' ```release-note:enhancement resource/aws_default_route_table: Add `core_network_arn` argument to the `route` configuration block -``` \ No newline at end of file +``` + +```release-note:enhancement +resource/aws_vpn_connection: Add `core_network_arn` and `core_network_attachment_arn` attributes +``` diff --git a/internal/service/ec2/vpn_connection.go b/internal/service/ec2/vpn_connection.go index 227cb41a8c8..b110d3a502c 100644 --- a/internal/service/ec2/vpn_connection.go +++ b/internal/service/ec2/vpn_connection.go @@ -37,6 +37,14 @@ func ResourceVPNConnection() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "core_network_arn": { + Type: schema.TypeString, + Computed: true, + }, + "core_network_attachment_arn": { + Type: schema.TypeString, + Computed: true, + }, "customer_gateway_configuration": { Type: schema.TypeString, Sensitive: true, @@ -633,6 +641,8 @@ func resourceVPNConnectionRead(d *schema.ResourceData, meta interface{}) error { Resource: fmt.Sprintf("vpn-connection/%s", d.Id()), }.String() d.Set("arn", arn) + d.Set("core_network_arn", vpnConnection.CoreNetworkArn) + d.Set("core_network_attachment_arn", vpnConnection.CoreNetworkAttachmentArn) d.Set("customer_gateway_id", vpnConnection.CustomerGatewayId) d.Set("type", vpnConnection.Type) d.Set("vpn_gateway_id", vpnConnection.VpnGatewayId) diff --git a/internal/service/ec2/vpn_connection_test.go b/internal/service/ec2/vpn_connection_test.go index 085e898b506..4ac73568c19 100644 --- a/internal/service/ec2/vpn_connection_test.go +++ b/internal/service/ec2/vpn_connection_test.go @@ -163,6 +163,8 @@ func TestAccEC2VPNConnection_basic(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccVPNConnectionExists(resourceName, &vpn), acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "ec2", regexp.MustCompile(`vpn-connection/vpn-.+`)), + resource.TestCheckResourceAttr(resourceName, "core_network_arn", ""), + resource.TestCheckResourceAttr(resourceName, "core_network_attachment_arn", ""), resource.TestCheckResourceAttrSet(resourceName, "customer_gateway_configuration"), resource.TestCheckResourceAttr(resourceName, "enable_acceleration", "false"), resource.TestCheckResourceAttr(resourceName, "local_ipv4_network_cidr", "0.0.0.0/0"), diff --git a/website/docs/r/vpn_connection.html.markdown b/website/docs/r/vpn_connection.html.markdown index 7c5d10b42e7..670995eadcb 100644 --- a/website/docs/r/vpn_connection.html.markdown +++ b/website/docs/r/vpn_connection.html.markdown @@ -127,6 +127,8 @@ In addition to all arguments above, the following attributes are exported: * `arn` - Amazon Resource Name (ARN) of the VPN Connection. * `id` - The amazon-assigned ID of the VPN connection. +* `core_network_arn` - The ARN of the core network. +* `core_network_attachment_arn` - The ARN of the core network attachment. * `customer_gateway_configuration` - The configuration information for the VPN connection's customer gateway (in the native XML format). * `customer_gateway_id` - The ID of the customer gateway to which the connection is attached. * `routes` - The static routes associated with the VPN connection. Detailed below. From b1f628068ebe2579c0a9bd3cef9055b1ac2692a6 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 5 Apr 2022 09:23:36 -0400 Subject: [PATCH 11/12] Fix typo. --- internal/service/ec2/route.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/ec2/route.go b/internal/service/ec2/route.go index 73c1cc9d938..e6e7c24f455 100644 --- a/internal/service/ec2/route.go +++ b/internal/service/ec2/route.go @@ -295,7 +295,7 @@ func resourceRouteRead(d *schema.ResourceData, meta interface{}) error { } d.Set("carrier_gateway_id", route.CarrierGatewayId) - d.Set("nat_gatcore_network_arneway_id", route.CoreNetworkArn) + d.Set("core_network_arn", route.CoreNetworkArn) d.Set("destination_cidr_block", route.DestinationCidrBlock) d.Set("destination_ipv6_cidr_block", route.DestinationIpv6CidrBlock) d.Set("destination_prefix_list_id", route.DestinationPrefixListId) From a45997cc11eefa2f5677a7e05ecc63139d107be5 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 5 Apr 2022 09:25:17 -0400 Subject: [PATCH 12/12] Fix typo. --- internal/service/ec2/route_table.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/ec2/route_table.go b/internal/service/ec2/route_table.go index c6abff4cdda..ce0e981153f 100644 --- a/internal/service/ec2/route_table.go +++ b/internal/service/ec2/route_table.go @@ -757,7 +757,7 @@ func expandEc2ReplaceRouteInput(tfMap map[string]interface{}) *ec2.ReplaceRouteI } if v, ok := tfMap["core_network_arn"].(string); ok && v != "" { - apiObject.CarrierGatewayId = aws.String(v) + apiObject.CoreNetworkArn = aws.String(v) } if v, ok := tfMap["egress_only_gateway_id"].(string); ok && v != "" {