Allow empty route_table_ids in aws_vpc_endpoint
This commit is contained in:
parent
6edbe2faf3
commit
84d943fc82
|
@ -59,9 +59,15 @@ func resourceAwsVpcEndpoint() *schema.Resource {
|
||||||
func resourceAwsVPCEndpointCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsVPCEndpointCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
conn := meta.(*AWSClient).ec2conn
|
conn := meta.(*AWSClient).ec2conn
|
||||||
input := &ec2.CreateVpcEndpointInput{
|
input := &ec2.CreateVpcEndpointInput{
|
||||||
VpcId: aws.String(d.Get("vpc_id").(string)),
|
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)),
|
||||||
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 {
|
if v, ok := d.GetOk("policy"); ok {
|
||||||
|
|
|
@ -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 = `
|
const testAccVpcEndpointWithRouteTableAndPolicyConfig = `
|
||||||
resource "aws_vpc" "foo" {
|
resource "aws_vpc" "foo" {
|
||||||
cidr_block = "10.0.0.0/16"
|
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}"
|
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"
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
Loading…
Reference in New Issue