Skip to content

Commit 46270d8

Browse files
committed
Add parameterized resource identity to aws_route_table
Adds resource identity support to the `aws_route_table` resource. This is a parameterized resource with a single attribute, `id`, corresponding to the route table ID generated by AWS during creation. ```console % make testacc PKG=vpc TESTS=TestAccVPCRouteTable_ make: Verifying source code with gofmt... ==> Checking that code complies with gofmt requirements... TF_ACC=1 go1.24.6 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccVPCRouteTable_' -timeout 360m -vet=off 2025/08/21 13:17:04 Creating Terraform AWS Provider (SDKv2-style)... 2025/08/21 13:17:04 Initializing Terraform AWS Provider (SDKv2-style)... === NAME TestAccVPCRouteTable_ipv4ToCarrierGateway wavelength_carrier_gateway_test.go:198: skipping since no Wavelength Zones are available --- SKIP: TestAccVPCRouteTable_ipv4ToCarrierGateway (0.97s) === CONT TestAccVPCRouteTable_Disappears_subnetAssociation === NAME TestAccVPCRouteTable_ipv4ToLocalGateway vpc_route_table_test.go:495: skipping since no Outposts found --- SKIP: TestAccVPCRouteTable_ipv4ToLocalGateway (0.97s) === CONT TestAccVPCRouteTable_tags_EmptyMap --- PASS: TestAccVPCRouteTable_requireRouteTarget (19.75s) === CONT TestAccVPCRouteTable_ipv4ToNatGateway --- PASS: TestAccVPCRouteTable_disappears (28.20s) === CONT TestAccVPCRouteTable_conditionalCIDRBlock --- PASS: TestAccVPCRouteTable_Disappears_subnetAssociation (36.47s) === CONT TestAccVPCRouteTable_Identity_ExistingResource --- PASS: TestAccVPCRouteTable_ipv4ToVPCPeeringConnection (43.15s) === CONT TestAccVPCRouteTable_tags --- PASS: TestAccVPCRouteTable_gatewayVPCEndpoint (51.46s) === CONT TestAccVPCRouteTable_tags_DefaultTags_providerOnly --- PASS: TestAccVPCRouteTable_ipv4ToInternetGateway (54.56s) === CONT TestAccVPCRouteTable_tags_DefaultTags_overlapping --- PASS: TestAccVPCRouteTable_IPv6ToNetworkInterface_unattached (57.32s) === CONT TestAccVPCRouteTable_tags_DefaultTags_nonOverlapping --- PASS: TestAccVPCRouteTable_Identity_Basic (59.24s) === CONT TestAccVPCRouteTable_Identity_RegionOverride --- PASS: TestAccVPCRouteTable_vpcMultipleCIDRs (61.01s) === CONT TestAccVPCRouteTable_tags_ComputedTag_OnCreate --- PASS: TestAccVPCRouteTable_tags_null (62.69s) === CONT TestAccVPCRouteTable_basic === CONT TestAccVPCRouteTable_tags_IgnoreTags_Overlap_ResourceTag --- PASS: TestAccVPCRouteTable_tags_EmptyMap (62.09s) --- PASS: TestAccVPCRouteTable_tags_AddOnUpdate (69.31s) === CONT TestAccVPCRouteTable_tags_IgnoreTags_Overlap_DefaultTag --- PASS: TestAccVPCRouteTable_tags_DefaultTags_updateToProviderOnly (69.89s) === CONT TestAccVPCRouteTable_tags_ComputedTag_OnUpdate_Replace --- PASS: TestAccVPCRouteTable_tags_EmptyTag_OnCreate (71.42s) === CONT TestAccVPCRouteTable_tags_ComputedTag_OnUpdate_Add --- PASS: TestAccVPCRouteTable_ipv6ToEgressOnlyInternetGateway (73.04s) === CONT TestAccVPCRouteTable_tags_EmptyTag_OnUpdate_Replace --- PASS: TestAccVPCRouteTable_Route_mode (95.32s) === CONT TestAccVPCRouteTable_localRoute --- PASS: TestAccVPCRouteTable_basic (37.07s) === CONT TestAccVPCRouteTable_localRouteImportUpdate --- PASS: TestAccVPCRouteTable_conditionalCIDRBlock (73.56s) === CONT TestAccVPCRouteTable_localRouteAdoptUpdate --- PASS: TestAccVPCRouteTable_tags_ComputedTag_OnCreate (41.95s) === CONT TestAccVPCRouteTable_ipv4ToVPCEndpoint --- PASS: TestAccVPCRouteTable_ipv4ToInstance (104.02s) === CONT TestAccVPCRouteTable_tags_DefaultTags_emptyProviderOnlyTag --- PASS: TestAccVPCRouteTable_Identity_RegionOverride (51.99s) === CONT TestAccVPCRouteTable_tags_DefaultTags_nullNonOverlappingResourceTag --- PASS: TestAccVPCRouteTable_IPv4ToNetworkInterfaces_unattached (113.85s) === CONT TestAccVPCRouteTable_tags_DefaultTags_nullOverlappingResourceTag --- PASS: TestAccVPCRouteTable_Identity_ExistingResource (78.37s) === CONT TestAccVPCRouteTable_tags_EmptyTag_OnUpdate_Add --- PASS: TestAccVPCRouteTable_localRoute (39.07s) === CONT TestAccVPCRouteTable_ipv4ToTransitGateway --- PASS: TestAccVPCRouteTable_requireRouteDestination (138.48s) === CONT TestAccVPCRouteTable_prefixListToInternetGateway --- PASS: TestAccVPCRouteTable_tags_ComputedTag_OnUpdate_Replace (69.80s) === CONT TestAccVPCRouteTable_multipleRoutes --- PASS: TestAccVPCRouteTable_tags_EmptyTag_OnUpdate_Replace (70.14s) === CONT TestAccVPCRouteTable_tags_DefaultTags_emptyResourceTag --- PASS: TestAccVPCRouteTable_tags_ComputedTag_OnUpdate_Add (73.52s) === CONT TestAccVPCRouteTable_tags_DefaultTags_updateToResourceOnly --- PASS: TestAccVPCRouteTable_tags_DefaultTags_emptyProviderOnlyTag (43.76s) --- PASS: TestAccVPCRouteTable_tags_DefaultTags_nullNonOverlappingResourceTag (40.17s) --- PASS: TestAccVPCRouteTable_tags_DefaultTags_nullOverlappingResourceTag (41.32s) --- PASS: TestAccVPCRouteTable_tags_IgnoreTags_Overlap_DefaultTag (86.41s) --- PASS: TestAccVPCRouteTable_tags_IgnoreTags_Overlap_ResourceTag (93.90s) --- PASS: TestAccVPCRouteTable_tags_DefaultTags_nonOverlapping (107.59s) --- PASS: TestAccVPCRouteTable_tags_DefaultTags_overlapping (111.61s) --- PASS: TestAccVPCRouteTable_tags_DefaultTags_emptyResourceTag (29.39s) --- PASS: TestAccVPCRouteTable_tags (130.41s) --- PASS: TestAccVPCRouteTable_prefixListToInternetGateway (36.61s) --- PASS: TestAccVPCRouteTable_tags_DefaultTags_providerOnly (127.03s) --- PASS: TestAccVPCRouteTable_vgwRoutePropagation (178.90s) --- PASS: TestAccVPCRouteTable_localRouteAdoptUpdate (78.25s) --- PASS: TestAccVPCRouteTable_tags_EmptyTag_OnUpdate_Add (72.19s) --- PASS: TestAccVPCRouteTable_tags_DefaultTags_updateToResourceOnly (43.74s) --- PASS: TestAccVPCRouteTable_localRouteImportUpdate (102.11s) --- PASS: TestAccVPCRouteTable_ipv4ToNatGateway (197.80s) --- PASS: TestAccVPCRouteTable_multipleRoutes (143.25s) --- PASS: TestAccVPCRouteTable_ipv4ToVPCEndpoint (370.55s) --- PASS: TestAccVPCRouteTable_ipv4ToTransitGateway (399.89s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/service/ec2 540.977s ```
1 parent 3b30f26 commit 46270d8

File tree

7 files changed

+293
-5
lines changed

7 files changed

+293
-5
lines changed

internal/service/ec2/service_package_gen.go

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (c) HashiCorp, Inc.
2+
# SPDX-License-Identifier: MPL-2.0
3+
4+
resource "aws_route_table" "test" {
5+
vpc_id = aws_vpc.test.id
6+
}
7+
8+
resource "aws_vpc" "test" {
9+
cidr_block = "10.1.0.0/16"
10+
}
11+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) HashiCorp, Inc.
2+
# SPDX-License-Identifier: MPL-2.0
3+
4+
resource "aws_route_table" "test" {
5+
vpc_id = aws_vpc.test.id
6+
}
7+
8+
resource "aws_vpc" "test" {
9+
cidr_block = "10.1.0.0/16"
10+
}
11+
12+
terraform {
13+
required_providers {
14+
aws = {
15+
source = "hashicorp/aws"
16+
version = "6.9.0"
17+
}
18+
}
19+
}
20+
21+
provider "aws" {}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) HashiCorp, Inc.
2+
# SPDX-License-Identifier: MPL-2.0
3+
4+
resource "aws_route_table" "test" {
5+
region = var.region
6+
7+
vpc_id = aws_vpc.test.id
8+
}
9+
10+
resource "aws_vpc" "test" {
11+
region = var.region
12+
13+
cidr_block = "10.1.0.0/16"
14+
}
15+
16+
17+
variable "region" {
18+
description = "Region to deploy resource in"
19+
type = string
20+
nullable = false
21+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
resource "aws_route_table" "test" {
2+
{{- template "region" }}
23
vpc_id = aws_vpc.test.id
34

45
{{- template "tags" . }}
56
}
67

78
resource "aws_vpc" "test" {
9+
{{- template "region" }}
810
cidr_block = "10.1.0.0/16"
911
}

internal/service/ec2/vpc_route_table.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,15 @@ var routeTableValidTargets = []string{
5151
// @Tags(identifierAttribute="id")
5252
// @Testing(existsType="github.com/aws/aws-sdk-go-v2/service/ec2/types;awstypes;awstypes.RouteTable")
5353
// @Testing(generator=false)
54+
// @IdentityAttribute("id")
55+
// @Testing(preIdentityVersion="v6.9.0")
5456
func resourceRouteTable() *schema.Resource {
5557
return &schema.Resource{
5658
CreateWithoutTimeout: resourceRouteTableCreate,
5759
ReadWithoutTimeout: resourceRouteTableRead,
5860
UpdateWithoutTimeout: resourceRouteTableUpdate,
5961
DeleteWithoutTimeout: resourceRouteTableDelete,
6062

61-
Importer: &schema.ResourceImporter{
62-
StateContext: schema.ImportStatePassthroughContext,
63-
},
64-
6563
Timeouts: &schema.ResourceTimeout{
6664
Create: schema.DefaultTimeout(5 * time.Minute),
6765
Update: schema.DefaultTimeout(2 * time.Minute),

internal/service/ec2/vpc_route_table_identity_gen_test.go

Lines changed: 231 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)