VPC Endpoint test updates

This commit is contained in:
clint shryock 2015-12-22 12:05:01 -06:00
parent 05983fde21
commit c3d987ab18
2 changed files with 13 additions and 14 deletions

View File

@ -5,6 +5,7 @@ import (
"testing" "testing"
"github.com/aws/aws-sdk-go/aws" "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/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
@ -20,9 +21,9 @@ func TestAccAWSVpcEndpoint_basic(t *testing.T) {
CheckDestroy: testAccCheckVpcEndpointDestroy, CheckDestroy: testAccCheckVpcEndpointDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testAccVpcEndpointConfig, Config: testAccVpcEndpointWithRouteTableAndPolicyConfig,
Check: resource.ComposeTestCheckFunc( 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)}, VpcEndpointIds: []*string{aws.String(rs.Primary.ID)},
} }
resp, err := conn.DescribeVpcEndpoints(input) 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 { if len(resp.VpcEndpoints) > 0 {
return fmt.Errorf("VPC Endpoints still exist.") 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 = ` const testAccVpcEndpointWithRouteTableAndPolicyConfig = `
resource "aws_vpc" "foo" { resource "aws_vpc" "foo" {
cidr_block = "10.0.0.0/16" cidr_block = "10.0.0.0/16"

View File

@ -37,6 +37,9 @@ func TestAccAWSVPCPeeringConnection_basic(t *testing.T) {
func TestAccAWSVPCPeeringConnection_tags(t *testing.T) { func TestAccAWSVPCPeeringConnection_tags(t *testing.T) {
var connection ec2.VpcPeeringConnection var connection ec2.VpcPeeringConnection
peerId := os.Getenv("TF_PEER_ID") 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{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },