From 8aa6b1276a6106a9e07dad55d1e73020e09b1e55 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 30 Dec 2020 08:39:53 -0500 Subject: [PATCH 1/7] r/aws_route: Incorporate relevant changes from #16219. --- aws/data_source_aws_route.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/aws/data_source_aws_route.go b/aws/data_source_aws_route.go index 0a3afb6225c..e4cae3faf03 100644 --- a/aws/data_source_aws_route.go +++ b/aws/data_source_aws_route.go @@ -187,3 +187,16 @@ func dataSourceAwsRouteRead(d *schema.ResourceData, meta interface{}) error { return nil } + +// Helper: Create an ID for a route +func resourceAwsRouteID(d *schema.ResourceData, r *ec2.Route) string { + routeTableID := d.Get("route_table_id").(string) + + if destination := aws.StringValue(r.DestinationCidrBlock); destination != "" { + return tfec2.RouteCreateID(routeTableID, destination) + } else if destination := aws.StringValue(r.DestinationIpv6CidrBlock); destination != "" { + return tfec2.RouteCreateID(routeTableID, destination) + } + + return "" +} From 13b4009f9a92744138376765ddd6dd0c2dd4aad5 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 26 Jan 2021 17:12:37 -0500 Subject: [PATCH 2/7] Add CHANGELOG entries. --- .changelog/#####.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changelog/#####.txt diff --git a/.changelog/#####.txt b/.changelog/#####.txt new file mode 100644 index 00000000000..70dcb8909f9 --- /dev/null +++ b/.changelog/#####.txt @@ -0,0 +1,7 @@ +```release-notes:enhancement +data-source/aws_route: Add `destination_prefix_list_id` attribute +``` + +```release-notes:enhancement +data-source/aws_route: Add `vpc_endpoint_id` attribute +``` From 50e88ab0a684369d8e01e528b9161b69b9f36c05 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 26 Jan 2021 18:20:03 -0500 Subject: [PATCH 3/7] d/aws_route: 'destination_prefix_list_id' attribute can be specified for managed prefix list destinations. --- aws/data_source_aws_route.go | 35 +++++- aws/data_source_aws_route_test.go | 164 +++++++++++++++++++++++++++++ website/docs/d/route.html.markdown | 1 + 3 files changed, 198 insertions(+), 2 deletions(-) diff --git a/aws/data_source_aws_route.go b/aws/data_source_aws_route.go index e4cae3faf03..eed430edac9 100644 --- a/aws/data_source_aws_route.go +++ b/aws/data_source_aws_route.go @@ -2,6 +2,7 @@ package aws import ( "fmt" + "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" @@ -34,6 +35,12 @@ func dataSourceAwsRoute() *schema.Resource { Computed: true, }, + "destination_prefix_list_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + // // Targets. // @@ -77,6 +84,11 @@ func dataSourceAwsRoute() *schema.Resource { Optional: true, Computed: true, }, + "vpc_endpoint_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, "vpc_peering_connection_id": { Type: schema.TypeString, Optional: true, @@ -104,7 +116,7 @@ func dataSourceAwsRouteRead(d *schema.ResourceData, meta interface{}) error { continue } - if r.DestinationPrefixListId != nil { + if r.DestinationPrefixListId != nil && strings.HasPrefix(aws.StringValue(r.GatewayId), "vpce-") { // Skipping because VPC endpoint routes are handled separately // See aws_vpc_endpoint continue @@ -118,6 +130,10 @@ func dataSourceAwsRouteRead(d *schema.ResourceData, meta interface{}) error { continue } + if v, ok := d.GetOk("destination_prefix_list_id"); ok && aws.StringValue(r.DestinationPrefixListId) != v.(string) { + continue + } + if v, ok := d.GetOk("carrier_gateway_id"); ok && aws.StringValue(r.CarrierGatewayId) != v.(string) { continue } @@ -150,6 +166,11 @@ func dataSourceAwsRouteRead(d *schema.ResourceData, meta interface{}) error { continue } + // VPC Endpoint ID for a Gateway Load Balancer target is returned in the Gateway ID field. + if v, ok := d.GetOk("vpc_endpoint_id"); ok && aws.StringValue(r.GatewayId) != v.(string) { + continue + } + if v, ok := d.GetOk("vpc_peering_connection_id"); ok && aws.StringValue(r.VpcPeeringConnectionId) != v.(string) { continue } @@ -171,13 +192,23 @@ func dataSourceAwsRouteRead(d *schema.ResourceData, meta interface{}) error { d.SetId(tfec2.RouteCreateID(routeTableID, destination)) } else if destination := aws.StringValue(route.DestinationIpv6CidrBlock); destination != "" { d.SetId(tfec2.RouteCreateID(routeTableID, destination)) + } else if destination := aws.StringValue(route.DestinationPrefixListId); destination != "" { + d.SetId(tfec2.RouteCreateID(routeTableID, destination)) } d.Set("carrier_gateway_id", route.CarrierGatewayId) d.Set("destination_cidr_block", route.DestinationCidrBlock) d.Set("destination_ipv6_cidr_block", route.DestinationIpv6CidrBlock) + d.Set("destination_prefix_list_id", route.DestinationPrefixListId) d.Set("egress_only_gateway_id", route.EgressOnlyInternetGatewayId) - d.Set("gateway_id", route.GatewayId) + // VPC Endpoint ID is returned in Gateway ID field + if strings.HasPrefix(aws.StringValue(route.GatewayId), "vpce-") { + d.Set("gateway_id", "") + d.Set("vpc_endpoint_id", route.GatewayId) + } else { + d.Set("gateway_id", route.GatewayId) + d.Set("vpc_endpoint_id", "") + } d.Set("instance_id", route.InstanceId) d.Set("local_gateway_id", route.LocalGatewayId) d.Set("nat_gateway_id", route.NatGatewayId) diff --git a/aws/data_source_aws_route_test.go b/aws/data_source_aws_route_test.go index 6a6228378db..5e445311123 100644 --- a/aws/data_source_aws_route_test.go +++ b/aws/data_source_aws_route_test.go @@ -2,6 +2,7 @@ package aws import ( "fmt" + "regexp" "testing" "github.com/aws/aws-sdk-go/service/ec2" @@ -138,6 +139,56 @@ func TestAccAWSRouteDataSource_CarrierGatewayID(t *testing.T) { }) } +func TestAccAWSRouteDataSource_DestinationPrefixListId(t *testing.T) { + dataSourceName := "data.aws_route.test" + resourceName := "aws_route.test" + rName := acctest.RandomWithPrefix("tf-acc-test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSRouteDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSRouteDataSourceConfigPrefixListNatGateway(rName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrPair(resourceName, "destination_prefix_list_id", dataSourceName, "destination_prefix_list_id"), + resource.TestCheckResourceAttrPair(resourceName, "nat_gateway_id", dataSourceName, "nat_gateway_id"), + resource.TestCheckResourceAttrPair(resourceName, "route_table_id", dataSourceName, "route_table_id"), + ), + }, + }, + }) +} + +func TestAccAWSRouteDataSource_GatewayVpcEndpoint(t *testing.T) { + var routeTable ec2.RouteTable + var vpce ec2.VpcEndpoint + rtResourceName := "aws_route_table.test" + vpceResourceName := "aws_vpc_endpoint.test" + rName := acctest.RandomWithPrefix("tf-acc-test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSRouteDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSRouteDataSourceConfigGatewayVpcEndpointNoDataSource(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckRouteTableExists(rtResourceName, &routeTable), + testAccCheckVpcEndpointExists(vpceResourceName, &vpce), + testAccCheckAWSRouteTableWaitForVpcEndpointRoute(&routeTable, &vpce), + ), + }, + { + Config: testAccAWSRouteDataSourceConfigGatewayVpcEndpointWithDataSource(rName), + ExpectError: regexp.MustCompile(`No routes matching supplied arguments found in Route Table`), + }, + }, + }) +} + func testAccDataSourceAwsRouteConfigBasic(rName string) string { return composeConfig( testAccLatestAmazonLinuxHvmEbsAmiConfig(), @@ -414,3 +465,116 @@ data "aws_route" "test" { } `, rName) } + +func testAccAWSRouteDataSourceConfigPrefixListNatGateway(rName string) string { + return fmt.Sprintf(` +resource "aws_vpc" "test" { + cidr_block = "10.1.0.0/16" + + tags = { + Name = %[1]q + } +} + +resource "aws_subnet" "test" { + cidr_block = "10.1.1.0/24" + vpc_id = aws_vpc.test.id + + map_public_ip_on_launch = true + + tags = { + Name = %[1]q + } +} + +resource "aws_internet_gateway" "test" { + vpc_id = aws_vpc.test.id + + tags = { + Name = %[1]q + } +} + +resource "aws_eip" "test" { + vpc = true + + tags = { + Name = %[1]q + } +} + +resource "aws_nat_gateway" "test" { + allocation_id = aws_eip.test.id + subnet_id = aws_subnet.test.id + + tags = { + Name = %[1]q + } + + depends_on = [aws_internet_gateway.test] +} + +resource "aws_ec2_managed_prefix_list" "test" { + address_family = "IPv4" + max_entries = 1 + name = %[1]q +} + +resource "aws_route_table" "test" { + vpc_id = aws_vpc.test.id + + tags = { + Name = %[1]q + } +} + +resource "aws_route" "test" { + route_table_id = aws_route_table.test.id + destination_prefix_list_id = aws_ec2_managed_prefix_list.test.id + nat_gateway_id = aws_nat_gateway.test.id +} + +data "aws_route" "test" { + route_table_id = aws_route.test.route_table_id + destination_prefix_list_id = aws_route.test.destination_prefix_list_id + nat_gateway_id = aws_route.test.nat_gateway_id +} +`, rName) +} + +func testAccAWSRouteDataSourceConfigGatewayVpcEndpointNoDataSource(rName string) string { + return fmt.Sprintf(` +resource "aws_vpc" "test" { + cidr_block = "10.1.0.0/16" + + tags = { + Name = %[1]q + } +} + +data "aws_region" "current" {} + +resource "aws_vpc_endpoint" "test" { + vpc_id = aws_vpc.test.id + service_name = "com.amazonaws.${data.aws_region.current.name}.s3" + route_table_ids = [aws_route_table.test.id] +} + +resource "aws_route_table" "test" { + vpc_id = aws_vpc.test.id + + tags = { + Name = %[1]q + } +} +`, rName) +} + +func testAccAWSRouteDataSourceConfigGatewayVpcEndpointWithDataSource(rName string) string { + return composeConfig(testAccAWSRouteDataSourceConfigGatewayVpcEndpointNoDataSource(rName), ` +data "aws_route" "test" { + route_table_id = aws_route_table.test.id + vpc_endpoint_id = aws_vpc_endpoint.test.id +} + `) +} diff --git a/website/docs/d/route.html.markdown b/website/docs/d/route.html.markdown index bb2293c2c3a..38d0c4fdb3f 100644 --- a/website/docs/d/route.html.markdown +++ b/website/docs/d/route.html.markdown @@ -46,6 +46,7 @@ The following arguments are optional: * `carrier_gateway_id` - (Optional) EC2 Carrier Gateway ID 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. * `egress_only_gateway_id` - (Optional) Egress Only Gateway ID of the Route belonging to the Route Table. * `gateway_id` - (Optional) Gateway ID of the Route belonging to the Route Table. * `instance_id` - (Optional) Instance ID of the Route belonging to the Route Table. From e4fdd608ec6d050cd2752c9d66d80b220ad4aa26 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 26 Jan 2021 18:22:36 -0500 Subject: [PATCH 4/7] Correct CHANGELOG file name. --- .changelog/{#####.txt => 17295.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .changelog/{#####.txt => 17295.txt} (100%) diff --git a/.changelog/#####.txt b/.changelog/17295.txt similarity index 100% rename from .changelog/#####.txt rename to .changelog/17295.txt From ad97f1d6795d3d66bb561032020ec83399936ae8 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 27 Jan 2021 08:56:01 -0500 Subject: [PATCH 5/7] d/aws_route: Don't add 'vpc_endpoint_id' attribute in this PR. --- .changelog/17295.txt | 4 ---- aws/data_source_aws_route.go | 14 +------------- aws/data_source_aws_route_test.go | 8 ++++++-- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/.changelog/17295.txt b/.changelog/17295.txt index 70dcb8909f9..1aa7f7f378d 100644 --- a/.changelog/17295.txt +++ b/.changelog/17295.txt @@ -1,7 +1,3 @@ ```release-notes:enhancement data-source/aws_route: Add `destination_prefix_list_id` attribute ``` - -```release-notes:enhancement -data-source/aws_route: Add `vpc_endpoint_id` attribute -``` diff --git a/aws/data_source_aws_route.go b/aws/data_source_aws_route.go index eed430edac9..e1bbb838bae 100644 --- a/aws/data_source_aws_route.go +++ b/aws/data_source_aws_route.go @@ -166,11 +166,6 @@ func dataSourceAwsRouteRead(d *schema.ResourceData, meta interface{}) error { continue } - // VPC Endpoint ID for a Gateway Load Balancer target is returned in the Gateway ID field. - if v, ok := d.GetOk("vpc_endpoint_id"); ok && aws.StringValue(r.GatewayId) != v.(string) { - continue - } - if v, ok := d.GetOk("vpc_peering_connection_id"); ok && aws.StringValue(r.VpcPeeringConnectionId) != v.(string) { continue } @@ -201,14 +196,7 @@ func dataSourceAwsRouteRead(d *schema.ResourceData, meta interface{}) error { d.Set("destination_ipv6_cidr_block", route.DestinationIpv6CidrBlock) d.Set("destination_prefix_list_id", route.DestinationPrefixListId) d.Set("egress_only_gateway_id", route.EgressOnlyInternetGatewayId) - // VPC Endpoint ID is returned in Gateway ID field - if strings.HasPrefix(aws.StringValue(route.GatewayId), "vpce-") { - d.Set("gateway_id", "") - d.Set("vpc_endpoint_id", route.GatewayId) - } else { - d.Set("gateway_id", route.GatewayId) - d.Set("vpc_endpoint_id", "") - } + d.Set("gateway_id", route.GatewayId) d.Set("instance_id", route.InstanceId) d.Set("local_gateway_id", route.LocalGatewayId) d.Set("nat_gateway_id", route.NatGatewayId) diff --git a/aws/data_source_aws_route_test.go b/aws/data_source_aws_route_test.go index 5e445311123..a44ff8010d3 100644 --- a/aws/data_source_aws_route_test.go +++ b/aws/data_source_aws_route_test.go @@ -572,9 +572,13 @@ resource "aws_route_table" "test" { func testAccAWSRouteDataSourceConfigGatewayVpcEndpointWithDataSource(rName string) string { return composeConfig(testAccAWSRouteDataSourceConfigGatewayVpcEndpointNoDataSource(rName), ` +data "aws_prefix_list" "test" { + name = aws_vpc_endpoint.test.service_name +} + data "aws_route" "test" { - route_table_id = aws_route_table.test.id - vpc_endpoint_id = aws_vpc_endpoint.test.id + route_table_id = aws_route_table.test.id + destination_prefix_list_id = data.aws_prefix_list.test.id } `) } From b713c1fb3d00ba1a802509a66806c6debc1dec3a Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 28 Jan 2021 11:29:40 -0500 Subject: [PATCH 6/7] d/aws_route: Add acceptance test pre-check. Acceptance test output: $ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSRouteDataSource_DestinationPrefixListId' ACCTEST_PARALLELISM=2 ==> Checking that code complies with gofmt requirements... TF_ACC=1 go test ./aws -v -count 1 -parallel 2 -run=TestAccAWSRouteDataSource_DestinationPrefixListId -timeout 120m === RUN TestAccAWSRouteDataSource_DestinationPrefixListId === PAUSE TestAccAWSRouteDataSource_DestinationPrefixListId === CONT TestAccAWSRouteDataSource_DestinationPrefixListId --- PASS: TestAccAWSRouteDataSource_DestinationPrefixListId (220.65s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 220.742s --- aws/data_source_aws_route_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/data_source_aws_route_test.go b/aws/data_source_aws_route_test.go index a44ff8010d3..e94266a70b1 100644 --- a/aws/data_source_aws_route_test.go +++ b/aws/data_source_aws_route_test.go @@ -145,7 +145,7 @@ func TestAccAWSRouteDataSource_DestinationPrefixListId(t *testing.T) { rName := acctest.RandomWithPrefix("tf-acc-test") resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(t); testAccPreCheckEc2ManagedPrefixList(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSRouteDestroy, Steps: []resource.TestStep{ From 4964548de5bfed90a95adcfb4311cfb4fa832a0d Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Sat, 27 Mar 2021 17:48:35 -0400 Subject: [PATCH 7/7] d/aws_route: Add 'ErrorCheck' to new acceptance tests. Acceptance test output: $ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSRouteDataSource_' ACCTEST_PARALLELISM=2 ==> Checking that code complies with gofmt requirements... TF_ACC=1 go test ./aws -v -count 1 -parallel 2 -run=TestAccAWSRouteDataSource_ -timeout 180m === RUN TestAccAWSRouteDataSource_basic === PAUSE TestAccAWSRouteDataSource_basic === RUN TestAccAWSRouteDataSource_TransitGatewayID === PAUSE TestAccAWSRouteDataSource_TransitGatewayID === RUN TestAccAWSRouteDataSource_IPv6DestinationCidr === PAUSE TestAccAWSRouteDataSource_IPv6DestinationCidr === RUN TestAccAWSRouteDataSource_LocalGatewayID === PAUSE TestAccAWSRouteDataSource_LocalGatewayID === RUN TestAccAWSRouteDataSource_CarrierGatewayID === PAUSE TestAccAWSRouteDataSource_CarrierGatewayID === RUN TestAccAWSRouteDataSource_DestinationPrefixListId === PAUSE TestAccAWSRouteDataSource_DestinationPrefixListId === RUN TestAccAWSRouteDataSource_GatewayVpcEndpoint === PAUSE TestAccAWSRouteDataSource_GatewayVpcEndpoint === CONT TestAccAWSRouteDataSource_basic === CONT TestAccAWSRouteDataSource_CarrierGatewayID --- PASS: TestAccAWSRouteDataSource_CarrierGatewayID (26.22s) === CONT TestAccAWSRouteDataSource_GatewayVpcEndpoint --- PASS: TestAccAWSRouteDataSource_GatewayVpcEndpoint (44.20s) === CONT TestAccAWSRouteDataSource_DestinationPrefixListId --- PASS: TestAccAWSRouteDataSource_basic (109.30s) === CONT TestAccAWSRouteDataSource_IPv6DestinationCidr --- PASS: TestAccAWSRouteDataSource_IPv6DestinationCidr (24.56s) === CONT TestAccAWSRouteDataSource_LocalGatewayID data_source_aws_outposts_outposts_test.go:67: skipping since no Outposts found --- SKIP: TestAccAWSRouteDataSource_LocalGatewayID (0.59s) === CONT TestAccAWSRouteDataSource_TransitGatewayID --- PASS: TestAccAWSRouteDataSource_DestinationPrefixListId (220.48s) --- PASS: TestAccAWSRouteDataSource_TransitGatewayID (390.35s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 524.910s --- aws/data_source_aws_route.go | 18 ------------------ aws/data_source_aws_route_test.go | 2 ++ aws/resource_aws_default_route_table_test.go | 2 +- aws/resource_aws_route_table_test.go | 2 +- aws/resource_aws_route_test.go | 2 +- 5 files changed, 5 insertions(+), 21 deletions(-) diff --git a/aws/data_source_aws_route.go b/aws/data_source_aws_route.go index e1bbb838bae..c05f601dc6e 100644 --- a/aws/data_source_aws_route.go +++ b/aws/data_source_aws_route.go @@ -84,11 +84,6 @@ func dataSourceAwsRoute() *schema.Resource { Optional: true, Computed: true, }, - "vpc_endpoint_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - }, "vpc_peering_connection_id": { Type: schema.TypeString, Optional: true, @@ -206,16 +201,3 @@ func dataSourceAwsRouteRead(d *schema.ResourceData, meta interface{}) error { return nil } - -// Helper: Create an ID for a route -func resourceAwsRouteID(d *schema.ResourceData, r *ec2.Route) string { - routeTableID := d.Get("route_table_id").(string) - - if destination := aws.StringValue(r.DestinationCidrBlock); destination != "" { - return tfec2.RouteCreateID(routeTableID, destination) - } else if destination := aws.StringValue(r.DestinationIpv6CidrBlock); destination != "" { - return tfec2.RouteCreateID(routeTableID, destination) - } - - return "" -} diff --git a/aws/data_source_aws_route_test.go b/aws/data_source_aws_route_test.go index e94266a70b1..05d71a62de9 100644 --- a/aws/data_source_aws_route_test.go +++ b/aws/data_source_aws_route_test.go @@ -146,6 +146,7 @@ func TestAccAWSRouteDataSource_DestinationPrefixListId(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t); testAccPreCheckEc2ManagedPrefixList(t) }, + ErrorCheck: testAccErrorCheck(t, ec2.EndpointsID), Providers: testAccProviders, CheckDestroy: testAccCheckAWSRouteDestroy, Steps: []resource.TestStep{ @@ -170,6 +171,7 @@ func TestAccAWSRouteDataSource_GatewayVpcEndpoint(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, ec2.EndpointsID), Providers: testAccProviders, CheckDestroy: testAccCheckAWSRouteDestroy, Steps: []resource.TestStep{ diff --git a/aws/resource_aws_default_route_table_test.go b/aws/resource_aws_default_route_table_test.go index 054960468ab..3d50ba216b4 100644 --- a/aws/resource_aws_default_route_table_test.go +++ b/aws/resource_aws_default_route_table_test.go @@ -260,7 +260,7 @@ func TestAccAWSDefaultRouteTable_IPv4_To_VpcEndpoint(t *testing.T) { destinationCidr := "0.0.0.0/0" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(t); testAccPreCheckElbv2GatewayLoadBalancer(t) }, ErrorCheck: testAccErrorCheck(t, ec2.EndpointsID, "elasticloadbalancing"), Providers: testAccProviders, CheckDestroy: testAccCheckRouteTableDestroy, diff --git a/aws/resource_aws_route_table_test.go b/aws/resource_aws_route_table_test.go index 00ea7daeaac..0ed93bf05dd 100644 --- a/aws/resource_aws_route_table_test.go +++ b/aws/resource_aws_route_table_test.go @@ -559,7 +559,7 @@ func TestAccAWSRouteTable_IPv4_To_VpcEndpoint(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t); testAccPreCheckElbv2GatewayLoadBalancer(t) }, - ErrorCheck: testAccErrorCheck(t, ec2.EndpointsID), + ErrorCheck: testAccErrorCheck(t, ec2.EndpointsID, "elasticloadbalancing"), Providers: testAccProviders, CheckDestroy: testAccCheckRouteTableDestroy, Steps: []resource.TestStep{ diff --git a/aws/resource_aws_route_test.go b/aws/resource_aws_route_test.go index bb7e29e55de..2c48c46ef88 100644 --- a/aws/resource_aws_route_test.go +++ b/aws/resource_aws_route_test.go @@ -1397,7 +1397,7 @@ func TestAccAWSRoute_IPv4_To_VpcEndpoint(t *testing.T) { destinationCidr := "172.16.1.0/24" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(t); testAccPreCheckElbv2GatewayLoadBalancer(t) }, ErrorCheck: testAccErrorCheck(t, ec2.EndpointsID, "elasticloadbalancing"), Providers: testAccProviders, CheckDestroy: testAccCheckAWSRouteDestroy,