Skip to content

Commit

Permalink
Merge pull request #9357 from mrwacky42/f/vpce-empty-rtb
Browse files Browse the repository at this point in the history
Allow empty route_table_ids list in aws_vpc_endpoint resources
  • Loading branch information
catsby authored Oct 20, 2016
2 parents 63b1443 + 84d943f commit e6c2b7f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
12 changes: 9 additions & 3 deletions builtin/providers/aws/resource_aws_vpc_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ func resourceAwsVpcEndpoint() *schema.Resource {
func resourceAwsVPCEndpointCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ec2conn
input := &ec2.CreateVpcEndpointInput{
VpcId: aws.String(d.Get("vpc_id").(string)),
RouteTableIds: expandStringList(d.Get("route_table_ids").(*schema.Set).List()),
ServiceName: aws.String(d.Get("service_name").(string)),
VpcId: aws.String(d.Get("vpc_id").(string)),
ServiceName: aws.String(d.Get("service_name").(string)),
}

if v, ok := d.GetOk("route_table_ids"); ok {
list := v.(*schema.Set).List()
if len(list) > 0 {
input.RouteTableIds = expandStringList(list)
}
}

if v, ok := d.GetOk("policy"); ok {
Expand Down
31 changes: 31 additions & 0 deletions builtin/providers/aws/resource_aws_vpc_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,26 @@ func testAccCheckVpcEndpointPrefixListAvailable(n string) resource.TestCheckFunc
}
}

func TestAccAWSVpcEndpointWithoutRouteTableOrPolicyConfig(t *testing.T) {
var endpoint ec2.VpcEndpoint

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "aws_vpc_endpoint.second-private-s3",
Providers: testAccProviders,
CheckDestroy: testAccCheckVpcEndpointDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccVpcEndpointWithoutRouteTableOrPolicyConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckVpcEndpointExists("aws_vpc_endpoint.second-private-s3", &endpoint),
testAccCheckVpcEndpointPrefixListAvailable("aws_vpc_endpoint.second-private-s3"),
),
},
},
})
}

const testAccVpcEndpointWithRouteTableAndPolicyConfig = `
resource "aws_vpc" "foo" {
cidr_block = "10.0.0.0/16"
Expand Down Expand Up @@ -227,3 +247,14 @@ resource "aws_route_table_association" "main" {
route_table_id = "${aws_route_table.default.id}"
}
`

const testAccVpcEndpointWithoutRouteTableOrPolicyConfig = `
resource "aws_vpc" "foo" {
cidr_block = "10.0.0.0/16"
}
resource "aws_vpc_endpoint" "second-private-s3" {
vpc_id = "${aws_vpc.foo.id}"
service_name = "com.amazonaws.us-west-2.s3"
}
`

0 comments on commit e6c2b7f

Please sign in to comment.