Skip to content

Commit

Permalink
r/aws_route: Add 'TestAccAWSRoute_IPv6_To_LocalGateway'.
Browse files Browse the repository at this point in the history
Acceptance test output:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSRoute_IPv6_To_LocalGateway' ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 2 -run=TestAccAWSRoute_IPv6_To_LocalGateway -timeout 120m
=== RUN   TestAccAWSRoute_IPv6_To_LocalGateway
=== PAUSE TestAccAWSRoute_IPv6_To_LocalGateway
=== CONT  TestAccAWSRoute_IPv6_To_LocalGateway
    data_source_aws_outposts_outposts_test.go:66: skipping since no Outposts Outpost found
--- SKIP: TestAccAWSRoute_IPv6_To_LocalGateway (2.13s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	2.185s
  • Loading branch information
ewbankkit committed Oct 18, 2020
1 parent 7899f7e commit d4c008a
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions aws/resource_aws_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,48 @@ func TestAccAWSRoute_IPv4_To_LocalGateway(t *testing.T) {
})
}

func TestAccAWSRoute_IPv6_To_LocalGateway(t *testing.T) {
var route ec2.Route
resourceName := "aws_route.test"
localGatewayDataSourceName := "data.aws_ec2_local_gateway.first"
rName := acctest.RandomWithPrefix("tf-acc-test")
destinationCidr := "2002:bc9:1234:1a00::/56"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSOutpostsOutposts(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSRouteDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSRouteResourceConfigIpv6LocalGateway(rName, destinationCidr),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSRouteExists(resourceName, &route),
resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", ""),
resource.TestCheckResourceAttr(resourceName, "destination_ipv6_cidr_block", destinationCidr),
resource.TestCheckResourceAttr(resourceName, "destination_prefix_list_id", ""),
resource.TestCheckResourceAttr(resourceName, "egress_only_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_owner_id", ""),
resource.TestCheckResourceAttrPair(resourceName, "local_gateway_id", localGatewayDataSourceName, "id"),
resource.TestCheckResourceAttr(resourceName, "nat_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "network_interface_id", ""),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
resource.TestCheckResourceAttr(resourceName, "state", ec2.RouteStateActive),
resource.TestCheckResourceAttr(resourceName, "transit_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "vpc_peering_connection_id", ""),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateIdFunc: testAccAWSRouteImportStateIdFunc(resourceName),
ImportStateVerify: true,
},
},
})
}

func TestAccAWSRoute_ConditionalCidrBlock(t *testing.T) {
var route ec2.Route
resourceName := "aws_route.test"
Expand Down Expand Up @@ -1553,6 +1595,56 @@ resource "aws_route" "test" {
`, rName, destinationCidr)
}

func testAccAWSRouteResourceConfigIpv6LocalGateway(rName, destinationCidr string) string {
return fmt.Sprintf(`
data "aws_ec2_local_gateways" "all" {}
data "aws_ec2_local_gateway" "first" {
id = tolist(data.aws_ec2_local_gateways.all.ids)[0]
}
data "aws_ec2_local_gateway_route_tables" "all" {}
data "aws_ec2_local_gateway_route_table" "first" {
local_gateway_route_table_id = tolist(data.aws_ec2_local_gateway_route_tables.all.ids)[0]
}
resource "aws_vpc" "test" {
cidr_block = "10.0.0.0/16"
assign_generated_ipv6_cidr_block = true
tags = {
Name = %[1]q
}
}
resource "aws_ec2_local_gateway_route_table_vpc_association" "example" {
local_gateway_route_table_id = data.aws_ec2_local_gateway_route_table.first.id
vpc_id = aws_vpc.test.id
tags = {
Name = %[1]q
}
}
resource "aws_route_table" "test" {
vpc_id = aws_vpc.test.id
tags = {
Name = %[1]q
}
depends_on = [aws_ec2_local_gateway_route_table_vpc_association.example]
}
resource "aws_route" "test" {
route_table_id = aws_route_table.test.id
destination_ipv6_cidr_block = %[2]q
local_gateway_id = data.aws_ec2_local_gateway.first.id
}
`, rName, destinationCidr)
}

func testAccAWSRouteConfigIpv4NetworkInterfaceAttached(rName, destinationCidr string) string {
return composeConfig(
testAccLatestAmazonNatInstanceAmiConfig(),
Expand Down

0 comments on commit d4c008a

Please sign in to comment.