diff --git a/builtin/providers/aws/resource_aws_vpc_peering_connection_test.go b/builtin/providers/aws/resource_aws_vpc_peering_connection_test.go index d89a7d22e..fe9b6a7c5 100644 --- a/builtin/providers/aws/resource_aws_vpc_peering_connection_test.go +++ b/builtin/providers/aws/resource_aws_vpc_peering_connection_test.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "reflect" + "regexp" "testing" "github.com/aws/aws-sdk-go/aws" @@ -190,6 +191,21 @@ func TestAccAWSVPCPeeringConnection_options(t *testing.T) { }) } +func TestAccAWSVPCPeeringConnection_failedState(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshIgnore: []string{"auto_accept"}, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSVpcPeeringConnectionDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccVpcPeeringConfigFailedState, + ExpectError: regexp.MustCompile(`.*Error waiting.*\(pcx-\w+\).*incorrect.*VPC-ID.*`), + }, + }, + }) +} + func testAccCheckAWSVpcPeeringConnectionDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).ec2conn @@ -368,3 +384,21 @@ resource "aws_vpc_peering_connection" "foo" { } } ` + +const testAccVpcPeeringConfigFailedState = ` +resource "aws_vpc" "foo" { + cidr_block = "10.0.0.0/16" + tags { + Name = "TestAccAWSVPCPeeringConnection_failedState" + } +} + +resource "aws_vpc" "bar" { + cidr_block = "10.0.0.0/16" +} + +resource "aws_vpc_peering_connection" "foo" { + vpc_id = "${aws_vpc.foo.id}" + peer_vpc_id = "${aws_vpc.bar.id}" +} +`