Skip to content

Commit

Permalink
Add 'TestAccAwsDxPrivateVirtualInterface_dxGateway'.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kit Ewbank authored and Kit Ewbank committed Jun 22, 2018
1 parent e3b13ce commit 4b7d622
Showing 1 changed file with 46 additions and 3 deletions.
49 changes: 46 additions & 3 deletions aws/resource_aws_dx_private_virtual_interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAccAwsDxPrivateVirtualInterface_basic(t *testing.T) {
if connectionId == "" {
t.Skipf("Environment variable %s is not set", key)
}
vifName := fmt.Sprintf("tf-dx-vif-%s", acctest.RandString(5))
vifName := fmt.Sprintf("terraform-testacc-dxvif-%s", acctest.RandString(5))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -52,6 +52,30 @@ func TestAccAwsDxPrivateVirtualInterface_basic(t *testing.T) {
})
}

func TestAccAwsDxPrivateVirtualInterface_dxGateway(t *testing.T) {
key := "DX_CONNECTION_ID"
connectionId := os.Getenv(key)
if connectionId == "" {
t.Skipf("Environment variable %s is not set", key)
}
vifName := fmt.Sprintf("terraform-testacc-dxvif-%s", acctest.RandString(5))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAwsDxPrivateVirtualInterfaceDestroy,
Steps: []resource.TestStep{
{
Config: testAccDxPrivateVirtualInterfaceConfig_dxGateway(connectionId, vifName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsDxPrivateVirtualInterfaceExists("aws_dx_private_virtual_interface.foo"),
resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "name", vifName),
),
},
},
})
}

func testAccCheckAwsDxPrivateVirtualInterfaceDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).dxconn

Expand Down Expand Up @@ -92,7 +116,7 @@ func testAccDxPrivateVirtualInterfaceConfig_noTags(cid, n string) string {
return fmt.Sprintf(`
resource "aws_vpn_gateway" "foo" {
tags {
Name = "Testing %s"
Name = "%s"
}
}
Expand All @@ -112,7 +136,7 @@ func testAccDxPrivateVirtualInterfaceConfig_tags(cid, n string) string {
return fmt.Sprintf(`
resource "aws_vpn_gateway" "foo" {
tags {
Name = "Testing %s"
Name = "%s"
}
}
Expand All @@ -131,3 +155,22 @@ resource "aws_dx_private_virtual_interface" "foo" {
}
`, n, cid, n)
}

func testAccDxPrivateVirtualInterfaceConfig_dxGateway(cid, n string) string {
return fmt.Sprintf(`
resource "aws_dx_gateway" "foo" {
name = "%s"
amazon_side_asn = 65351
}
resource "aws_dx_private_virtual_interface" "foo" {
connection_id = "%s"
dx_gateway_id = "${aws_dx_gateway.foo.id}"
name = "%s"
vlan = 4094
address_family = "ipv4"
bgp_asn = 65352
}
`, n, cid, n)
}

0 comments on commit 4b7d622

Please sign in to comment.