randomizes all bgp_asn values
This commit is contained in:
parent
e2d7d5fc68
commit
1b2653b0bd
|
@ -3,11 +3,14 @@ package aws
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccAWSCustomerGateway_importBasic(t *testing.T) {
|
func TestAccAWSCustomerGateway_importBasic(t *testing.T) {
|
||||||
resourceName := "aws_customer_gateway.foo"
|
resourceName := "aws_customer_gateway.foo"
|
||||||
|
rInt := acctest.RandInt()
|
||||||
|
rBgpAsn := acctest.RandIntRange(64512, 65534)
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -15,7 +18,7 @@ func TestAccAWSCustomerGateway_importBasic(t *testing.T) {
|
||||||
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccCustomerGatewayConfig,
|
Config: testAccCustomerGatewayConfig(rInt, rBgpAsn),
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
|
|
|
@ -3,11 +3,13 @@ package aws
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccAWSVpnConnection_importBasic(t *testing.T) {
|
func TestAccAWSVpnConnection_importBasic(t *testing.T) {
|
||||||
resourceName := "aws_vpn_connection.foo"
|
resourceName := "aws_vpn_connection.foo"
|
||||||
|
rBgpAsn := acctest.RandIntRange(64512, 65534)
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -15,7 +17,7 @@ func TestAccAWSVpnConnection_importBasic(t *testing.T) {
|
||||||
CheckDestroy: testAccAwsVpnConnectionDestroy,
|
CheckDestroy: testAccAwsVpnConnectionDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccAwsVpnConnectionConfig,
|
Config: testAccAwsVpnConnectionConfig(rBgpAsn),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ResourceName: resourceName,
|
ResourceName: resourceName,
|
||||||
|
|
|
@ -10,12 +10,15 @@ import (
|
||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/service/ec2"
|
"github.com/aws/aws-sdk-go/service/ec2"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccAWSCustomerGateway_basic(t *testing.T) {
|
func TestAccAWSCustomerGateway_basic(t *testing.T) {
|
||||||
var gateway ec2.CustomerGateway
|
var gateway ec2.CustomerGateway
|
||||||
|
rBgpAsn := acctest.RandIntRange(64512, 65534)
|
||||||
|
rInt := acctest.RandInt()
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
IDRefreshName: "aws_customer_gateway.foo",
|
IDRefreshName: "aws_customer_gateway.foo",
|
||||||
|
@ -23,19 +26,19 @@ func TestAccAWSCustomerGateway_basic(t *testing.T) {
|
||||||
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccCustomerGatewayConfig,
|
Config: testAccCustomerGatewayConfig(rInt, rBgpAsn),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Config: testAccCustomerGatewayConfigUpdateTags,
|
Config: testAccCustomerGatewayConfigUpdateTags(rInt, rBgpAsn),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Config: testAccCustomerGatewayConfigForceReplace,
|
Config: testAccCustomerGatewayConfigForceReplace(rInt, rBgpAsn),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
||||||
),
|
),
|
||||||
|
@ -46,6 +49,8 @@ func TestAccAWSCustomerGateway_basic(t *testing.T) {
|
||||||
|
|
||||||
func TestAccAWSCustomerGateway_similarAlreadyExists(t *testing.T) {
|
func TestAccAWSCustomerGateway_similarAlreadyExists(t *testing.T) {
|
||||||
var gateway ec2.CustomerGateway
|
var gateway ec2.CustomerGateway
|
||||||
|
rInt := acctest.RandInt()
|
||||||
|
rBgpAsn := acctest.RandIntRange(64512, 65534)
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
IDRefreshName: "aws_customer_gateway.foo",
|
IDRefreshName: "aws_customer_gateway.foo",
|
||||||
|
@ -53,13 +58,13 @@ func TestAccAWSCustomerGateway_similarAlreadyExists(t *testing.T) {
|
||||||
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccCustomerGatewayConfig,
|
Config: testAccCustomerGatewayConfig(rInt, rBgpAsn),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Config: testAccCustomerGatewayConfigIdentical,
|
Config: testAccCustomerGatewayConfigIdentical(rInt, rBgpAsn),
|
||||||
ExpectError: regexp.MustCompile("An existing customer gateway"),
|
ExpectError: regexp.MustCompile("An existing customer gateway"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -67,6 +72,8 @@ func TestAccAWSCustomerGateway_similarAlreadyExists(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAWSCustomerGateway_disappears(t *testing.T) {
|
func TestAccAWSCustomerGateway_disappears(t *testing.T) {
|
||||||
|
rInt := acctest.RandInt()
|
||||||
|
rBgpAsn := acctest.RandIntRange(64512, 65534)
|
||||||
var gateway ec2.CustomerGateway
|
var gateway ec2.CustomerGateway
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -74,7 +81,7 @@ func TestAccAWSCustomerGateway_disappears(t *testing.T) {
|
||||||
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccCustomerGatewayConfig,
|
Config: testAccCustomerGatewayConfig(rInt, rBgpAsn),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
||||||
testAccAWSCustomerGatewayDisappears(&gateway),
|
testAccAWSCustomerGatewayDisappears(&gateway),
|
||||||
|
@ -190,59 +197,66 @@ func testAccCheckCustomerGateway(gatewayResource string, cgw *ec2.CustomerGatewa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const testAccCustomerGatewayConfig = `
|
func testAccCustomerGatewayConfig(rInt, rBgpAsn int) string {
|
||||||
resource "aws_customer_gateway" "foo" {
|
return fmt.Sprintf(`
|
||||||
bgp_asn = 65000
|
resource "aws_customer_gateway" "foo" {
|
||||||
ip_address = "172.0.0.1"
|
bgp_asn = %d
|
||||||
type = "ipsec.1"
|
ip_address = "172.0.0.1"
|
||||||
tags {
|
type = "ipsec.1"
|
||||||
Name = "foo-gateway"
|
tags {
|
||||||
}
|
Name = "foo-gateway-%d"
|
||||||
}
|
}
|
||||||
`
|
}
|
||||||
|
`, rBgpAsn, rInt)
|
||||||
const testAccCustomerGatewayConfigIdentical = `
|
|
||||||
resource "aws_customer_gateway" "foo" {
|
|
||||||
bgp_asn = 65000
|
|
||||||
ip_address = "172.0.0.1"
|
|
||||||
type = "ipsec.1"
|
|
||||||
tags {
|
|
||||||
Name = "foo-gateway"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_customer_gateway" "identical" {
|
func testAccCustomerGatewayConfigIdentical(randInt, rBgpAsn int) string {
|
||||||
bgp_asn = 65000
|
return fmt.Sprintf(`
|
||||||
ip_address = "172.0.0.1"
|
resource "aws_customer_gateway" "foo" {
|
||||||
type = "ipsec.1"
|
bgp_asn = %d
|
||||||
tags {
|
ip_address = "172.0.0.1"
|
||||||
Name = "foo-gateway-identical"
|
type = "ipsec.1"
|
||||||
}
|
tags {
|
||||||
|
Name = "foo-gateway-%d"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resource "aws_customer_gateway" "identical" {
|
||||||
|
bgp_asn = %d
|
||||||
|
ip_address = "172.0.0.1"
|
||||||
|
type = "ipsec.1"
|
||||||
|
tags {
|
||||||
|
Name = "foo-gateway-identical-%d"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`, rBgpAsn, randInt, rBgpAsn, randInt)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
// Add the Another: "tag" tag.
|
// Add the Another: "tag" tag.
|
||||||
const testAccCustomerGatewayConfigUpdateTags = `
|
func testAccCustomerGatewayConfigUpdateTags(rInt, rBgpAsn int) string {
|
||||||
resource "aws_customer_gateway" "foo" {
|
return fmt.Sprintf(`
|
||||||
bgp_asn = 65000
|
resource "aws_customer_gateway" "foo" {
|
||||||
ip_address = "172.0.0.1"
|
bgp_asn = %d
|
||||||
type = "ipsec.1"
|
ip_address = "172.0.0.1"
|
||||||
tags {
|
type = "ipsec.1"
|
||||||
Name = "foo-gateway"
|
tags {
|
||||||
Another = "tag"
|
Name = "foo-gateway-%d"
|
||||||
|
Another = "tag"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
`, rBgpAsn, rInt)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
// Change the ip_address.
|
// Change the ip_address.
|
||||||
const testAccCustomerGatewayConfigForceReplace = `
|
func testAccCustomerGatewayConfigForceReplace(rInt, rBgpAsn int) string {
|
||||||
resource "aws_customer_gateway" "foo" {
|
return fmt.Sprintf(`
|
||||||
bgp_asn = 65000
|
resource "aws_customer_gateway" "foo" {
|
||||||
ip_address = "172.10.10.1"
|
bgp_asn = %d
|
||||||
type = "ipsec.1"
|
ip_address = "172.10.10.1"
|
||||||
tags {
|
type = "ipsec.1"
|
||||||
Name = "foo-gateway"
|
tags {
|
||||||
Another = "tag"
|
Name = "foo-gateway-%d"
|
||||||
}
|
Another = "tag"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`, rBgpAsn, rInt)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
|
|
||||||
func TestAccAWSVpnConnection_basic(t *testing.T) {
|
func TestAccAWSVpnConnection_basic(t *testing.T) {
|
||||||
rInt := acctest.RandInt()
|
rInt := acctest.RandInt()
|
||||||
|
rBgpAsn := acctest.RandIntRange(64512, 65534)
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
IDRefreshName: "aws_vpn_connection.foo",
|
IDRefreshName: "aws_vpn_connection.foo",
|
||||||
|
@ -22,7 +23,7 @@ func TestAccAWSVpnConnection_basic(t *testing.T) {
|
||||||
CheckDestroy: testAccAwsVpnConnectionDestroy,
|
CheckDestroy: testAccAwsVpnConnectionDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccAwsVpnConnectionConfig,
|
Config: testAccAwsVpnConnectionConfig(rBgpAsn),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccAwsVpnConnection(
|
testAccAwsVpnConnection(
|
||||||
"aws_vpc.vpc",
|
"aws_vpc.vpc",
|
||||||
|
@ -33,7 +34,7 @@ func TestAccAWSVpnConnection_basic(t *testing.T) {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Config: testAccAwsVpnConnectionConfigUpdate(rInt),
|
Config: testAccAwsVpnConnectionConfigUpdate(rInt, rBgpAsn),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccAwsVpnConnection(
|
testAccAwsVpnConnection(
|
||||||
"aws_vpc.vpc",
|
"aws_vpc.vpc",
|
||||||
|
@ -49,6 +50,7 @@ func TestAccAWSVpnConnection_basic(t *testing.T) {
|
||||||
|
|
||||||
func TestAccAWSVpnConnection_withoutStaticRoutes(t *testing.T) {
|
func TestAccAWSVpnConnection_withoutStaticRoutes(t *testing.T) {
|
||||||
rInt := acctest.RandInt()
|
rInt := acctest.RandInt()
|
||||||
|
rBgpAsn := acctest.RandIntRange(64512, 65534)
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
IDRefreshName: "aws_vpn_connection.foo",
|
IDRefreshName: "aws_vpn_connection.foo",
|
||||||
|
@ -56,7 +58,7 @@ func TestAccAWSVpnConnection_withoutStaticRoutes(t *testing.T) {
|
||||||
CheckDestroy: testAccAwsVpnConnectionDestroy,
|
CheckDestroy: testAccAwsVpnConnectionDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccAwsVpnConnectionConfigUpdate(rInt),
|
Config: testAccAwsVpnConnectionConfigUpdate(rInt, rBgpAsn),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccAwsVpnConnection(
|
testAccAwsVpnConnection(
|
||||||
"aws_vpc.vpc",
|
"aws_vpc.vpc",
|
||||||
|
@ -163,32 +165,34 @@ func TestAWSVpnConnection_xmlconfig(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const testAccAwsVpnConnectionConfig = `
|
func testAccAwsVpnConnectionConfig(rBgpAsn int) string {
|
||||||
resource "aws_vpn_gateway" "vpn_gateway" {
|
return fmt.Sprintf(`
|
||||||
tags {
|
resource "aws_vpn_gateway" "vpn_gateway" {
|
||||||
Name = "vpn_gateway"
|
tags {
|
||||||
}
|
Name = "vpn_gateway"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_customer_gateway" "customer_gateway" {
|
|
||||||
bgp_asn = 65000
|
|
||||||
ip_address = "178.0.0.1"
|
|
||||||
type = "ipsec.1"
|
|
||||||
tags {
|
|
||||||
Name = "main-customer-gateway"
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_vpn_connection" "foo" {
|
resource "aws_customer_gateway" "customer_gateway" {
|
||||||
vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}"
|
bgp_asn = %d
|
||||||
customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}"
|
ip_address = "178.0.0.1"
|
||||||
type = "ipsec.1"
|
type = "ipsec.1"
|
||||||
static_routes_only = true
|
tags {
|
||||||
}
|
Name = "main-customer-gateway"
|
||||||
`
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_vpn_connection" "foo" {
|
||||||
|
vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}"
|
||||||
|
customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}"
|
||||||
|
type = "ipsec.1"
|
||||||
|
static_routes_only = true
|
||||||
|
}
|
||||||
|
`, rBgpAsn)
|
||||||
|
}
|
||||||
|
|
||||||
// Change static_routes_only to be false, forcing a refresh.
|
// Change static_routes_only to be false, forcing a refresh.
|
||||||
func testAccAwsVpnConnectionConfigUpdate(rInt int) string {
|
func testAccAwsVpnConnectionConfigUpdate(rInt, rBgpAsn int) string {
|
||||||
return fmt.Sprintf(`
|
return fmt.Sprintf(`
|
||||||
resource "aws_vpn_gateway" "vpn_gateway" {
|
resource "aws_vpn_gateway" "vpn_gateway" {
|
||||||
tags {
|
tags {
|
||||||
|
@ -197,7 +201,7 @@ func testAccAwsVpnConnectionConfigUpdate(rInt int) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_customer_gateway" "customer_gateway" {
|
resource "aws_customer_gateway" "customer_gateway" {
|
||||||
bgp_asn = 65000
|
bgp_asn = %d
|
||||||
ip_address = "178.0.0.1"
|
ip_address = "178.0.0.1"
|
||||||
type = "ipsec.1"
|
type = "ipsec.1"
|
||||||
tags {
|
tags {
|
||||||
|
@ -211,7 +215,7 @@ func testAccAwsVpnConnectionConfigUpdate(rInt int) string {
|
||||||
type = "ipsec.1"
|
type = "ipsec.1"
|
||||||
static_routes_only = false
|
static_routes_only = false
|
||||||
}
|
}
|
||||||
`, rInt)
|
`, rBgpAsn, rInt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test our VPN tunnel config XML parsing
|
// Test our VPN tunnel config XML parsing
|
||||||
|
|
|
@ -8,18 +8,20 @@ import (
|
||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/service/ec2"
|
"github.com/aws/aws-sdk-go/service/ec2"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccAWSVpnConnectionRoute_basic(t *testing.T) {
|
func TestAccAWSVpnConnectionRoute_basic(t *testing.T) {
|
||||||
|
rBgpAsn := acctest.RandIntRange(64512, 65534)
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccAwsVpnConnectionRouteDestroy,
|
CheckDestroy: testAccAwsVpnConnectionRouteDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccAwsVpnConnectionRouteConfig,
|
Config: testAccAwsVpnConnectionRouteConfig(rBgpAsn),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccAwsVpnConnectionRoute(
|
testAccAwsVpnConnectionRoute(
|
||||||
"aws_vpn_gateway.vpn_gateway",
|
"aws_vpn_gateway.vpn_gateway",
|
||||||
|
@ -30,7 +32,7 @@ func TestAccAWSVpnConnectionRoute_basic(t *testing.T) {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccAwsVpnConnectionRouteConfigUpdate,
|
Config: testAccAwsVpnConnectionRouteConfigUpdate(rBgpAsn),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccAwsVpnConnectionRoute(
|
testAccAwsVpnConnectionRoute(
|
||||||
"aws_vpn_gateway.vpn_gateway",
|
"aws_vpn_gateway.vpn_gateway",
|
||||||
|
@ -143,55 +145,59 @@ func testAccAwsVpnConnectionRoute(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const testAccAwsVpnConnectionRouteConfig = `
|
func testAccAwsVpnConnectionRouteConfig(rBgpAsn int) string {
|
||||||
resource "aws_vpn_gateway" "vpn_gateway" {
|
return fmt.Sprintf(`
|
||||||
tags {
|
resource "aws_vpn_gateway" "vpn_gateway" {
|
||||||
Name = "vpn_gateway"
|
tags {
|
||||||
|
Name = "vpn_gateway"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_customer_gateway" "customer_gateway" {
|
resource "aws_customer_gateway" "customer_gateway" {
|
||||||
bgp_asn = 65000
|
bgp_asn = %d
|
||||||
ip_address = "182.0.0.1"
|
ip_address = "182.0.0.1"
|
||||||
type = "ipsec.1"
|
type = "ipsec.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_vpn_connection" "vpn_connection" {
|
resource "aws_vpn_connection" "vpn_connection" {
|
||||||
vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}"
|
vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}"
|
||||||
customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}"
|
customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}"
|
||||||
type = "ipsec.1"
|
type = "ipsec.1"
|
||||||
static_routes_only = true
|
static_routes_only = true
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_vpn_connection_route" "foo" {
|
resource "aws_vpn_connection_route" "foo" {
|
||||||
destination_cidr_block = "172.168.10.0/24"
|
destination_cidr_block = "172.168.10.0/24"
|
||||||
vpn_connection_id = "${aws_vpn_connection.vpn_connection.id}"
|
vpn_connection_id = "${aws_vpn_connection.vpn_connection.id}"
|
||||||
|
}
|
||||||
|
`, rBgpAsn)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
// Change destination_cidr_block
|
// Change destination_cidr_block
|
||||||
const testAccAwsVpnConnectionRouteConfigUpdate = `
|
func testAccAwsVpnConnectionRouteConfigUpdate(rBgpAsn int) string {
|
||||||
resource "aws_vpn_gateway" "vpn_gateway" {
|
return fmt.Sprintf(`
|
||||||
tags {
|
resource "aws_vpn_gateway" "vpn_gateway" {
|
||||||
Name = "vpn_gateway"
|
tags {
|
||||||
|
Name = "vpn_gateway"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_customer_gateway" "customer_gateway" {
|
resource "aws_customer_gateway" "customer_gateway" {
|
||||||
bgp_asn = 65000
|
bgp_asn = %d
|
||||||
ip_address = "182.0.0.1"
|
ip_address = "182.0.0.1"
|
||||||
type = "ipsec.1"
|
type = "ipsec.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_vpn_connection" "vpn_connection" {
|
resource "aws_vpn_connection" "vpn_connection" {
|
||||||
vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}"
|
vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}"
|
||||||
customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}"
|
customer_gateway_id = "${aws_customer_gateway.customer_gateway.id}"
|
||||||
type = "ipsec.1"
|
type = "ipsec.1"
|
||||||
static_routes_only = true
|
static_routes_only = true
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_vpn_connection_route" "foo" {
|
resource "aws_vpn_connection_route" "foo" {
|
||||||
destination_cidr_block = "172.168.20.0/24"
|
destination_cidr_block = "172.168.20.0/24"
|
||||||
vpn_connection_id = "${aws_vpn_connection.vpn_connection.id}"
|
vpn_connection_id = "${aws_vpn_connection.vpn_connection.id}"
|
||||||
|
}
|
||||||
|
`, rBgpAsn)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
Loading…
Reference in New Issue