From c3d987ab18fd794c37d7feeb71405e7f09a6c189 Mon Sep 17 00:00:00 2001 From: clint shryock Date: Tue, 22 Dec 2015 12:05:01 -0600 Subject: [PATCH] VPC Endpoint test updates --- .../aws/resource_aws_vpc_endpoint_test.go | 24 ++++++++----------- ...esource_aws_vpc_peering_connection_test.go | 3 +++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/builtin/providers/aws/resource_aws_vpc_endpoint_test.go b/builtin/providers/aws/resource_aws_vpc_endpoint_test.go index 7973cf8f0..4a081b69c 100644 --- a/builtin/providers/aws/resource_aws_vpc_endpoint_test.go +++ b/builtin/providers/aws/resource_aws_vpc_endpoint_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/terraform/helper/resource" @@ -20,9 +21,9 @@ func TestAccAWSVpcEndpoint_basic(t *testing.T) { CheckDestroy: testAccCheckVpcEndpointDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccVpcEndpointConfig, + Config: testAccVpcEndpointWithRouteTableAndPolicyConfig, Check: resource.ComposeTestCheckFunc( - testAccCheckVpcEndpointExists("aws_vpc_endpoint.private-s3", &endpoint), + testAccCheckVpcEndpointExists("aws_vpc_endpoint.second-private-s3", &endpoint), ), }, }, @@ -69,7 +70,13 @@ func testAccCheckVpcEndpointDestroy(s *terraform.State) error { VpcEndpointIds: []*string{aws.String(rs.Primary.ID)}, } resp, err := conn.DescribeVpcEndpoints(input) - + if err != nil { + // Verify the error is what we want + if ae, ok := err.(awserr.Error); ok && ae.Code() == "InvalidVpcEndpointId.NotFound" { + continue + } + return err + } if len(resp.VpcEndpoints) > 0 { return fmt.Errorf("VPC Endpoints still exist.") } @@ -109,17 +116,6 @@ func testAccCheckVpcEndpointExists(n string, endpoint *ec2.VpcEndpoint) resource } } -const testAccVpcEndpointConfig = ` -resource "aws_vpc" "foo" { - cidr_block = "10.1.0.0/16" -} - -resource "aws_vpc_endpoint" "private-s3" { - vpc_id = "${aws_vpc.foo.id}" - service_name = "com.amazonaws.us-west-2.s3" -} -` - const testAccVpcEndpointWithRouteTableAndPolicyConfig = ` resource "aws_vpc" "foo" { cidr_block = "10.0.0.0/16" 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 ca92ce66a..48f8bee85 100644 --- a/builtin/providers/aws/resource_aws_vpc_peering_connection_test.go +++ b/builtin/providers/aws/resource_aws_vpc_peering_connection_test.go @@ -37,6 +37,9 @@ func TestAccAWSVPCPeeringConnection_basic(t *testing.T) { func TestAccAWSVPCPeeringConnection_tags(t *testing.T) { var connection ec2.VpcPeeringConnection peerId := os.Getenv("TF_PEER_ID") + if peerId == "" { + t.Fatalf("Error: TestAccAWSVPCPeeringConnection_tags requires a peer id to be set") + } resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) },