diff --git a/.changelog/24024.txt b/.changelog/24024.txt new file mode 100644 index 00000000000..00a4c658261 --- /dev/null +++ b/.changelog/24024.txt @@ -0,0 +1,27 @@ +```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 +``` + +```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 +``` + +```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 +``` + +```release-note:enhancement +resource/aws_vpn_connection: Add `core_network_arn` and `core_network_attachment_arn` attributes +``` 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/internal/service/ec2/route.go b/internal/service/ec2/route.go index da26207275b..e6e7c24f455 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": @@ -239,14 +247,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) } @@ -287,6 +295,7 @@ func resourceRouteRead(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) @@ -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_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/internal/service/ec2/route_table.go b/internal/service/ec2/route_table.go index 3e99a0ff942..ce0e981153f 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.CoreNetworkArn = 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/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/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/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/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. 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. 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. 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. 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. 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.