VPC Endpoint test updates
This commit is contained in:
parent
05983fde21
commit
c3d987ab18
|
@ -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"
|
||||
|
|
|
@ -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) },
|
||||
|
|
Loading…
Reference in New Issue