Allow empty route_table_ids in aws_vpc_endpoint

This commit is contained in:
Sharif Nassar 2016-10-13 10:41:38 -07:00
parent 6edbe2faf3
commit 84d943fc82
2 changed files with 40 additions and 3 deletions

View File

@ -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 {

View File

@ -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"
@ -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"
}
`