Adding default network acl id attribute reference on creation of VPC. Fixes issue #466.

This commit is contained in:
Yahya Poonawala 2014-12-22 23:08:15 +05:30
parent fd6382fbaf
commit 634984532d
1 changed files with 24 additions and 0 deletions

View File

@ -47,6 +47,11 @@ func resourceAwsVpc() *schema.Resource {
Computed: true, Computed: true,
}, },
"default_network_acl_id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"tags": tagsSchema(), "tags": tagsSchema(),
}, },
} }
@ -139,6 +144,8 @@ func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
d.Set("main_route_table_id", v[0].RouteTableId) d.Set("main_route_table_id", v[0].RouteTableId)
} }
resourceAwsVpcSetDefaultNetworkAcl(ec2conn, d)
return nil return nil
} }
@ -228,3 +235,20 @@ func VPCStateRefreshFunc(conn *ec2.EC2, id string) resource.StateRefreshFunc {
return vpc, vpc.State, nil return vpc, vpc.State, nil
} }
} }
func resourceAwsVpcSetDefaultNetworkAcl(conn *ec2.EC2, d *schema.ResourceData) error {
filter := ec2.NewFilter()
filter.Add("default", "true")
filter.Add("vpc-id", d.Id())
networkAclResp, err := conn.NetworkAcls(nil, filter)
if err != nil {
return err
}
if v := networkAclResp.NetworkAcls; len(v) > 0 {
d.Set("default_network_acl_id", v[0].NetworkAclId)
}
return nil
}