providers/aws: main_route_table_id attribute for VPC [GH-193]

This commit is contained in:
Mitchell Hashimoto 2014-10-10 16:57:32 -07:00
parent 51d66b678d
commit e827180887
3 changed files with 22 additions and 3 deletions

View File

@ -43,6 +43,7 @@ IMPROVEMENTS:
`aws_launch_configuration`. [GH-371]
* providers/aws: Non-destructive update of `desired_capacity` for
autoscale groups.
* providers/aws: Add `main_route_table_id` attribute to VPCs. [GH-193]
* providers/google: Support `target_tags` for firewalls. [GH-324]
* providers/google: `google_compute_instance` supports `can_ip_forward` [GH-375]
* providers/google: `google_compute_disk` supports `type` to support disks

View File

@ -36,6 +36,11 @@ func resourceAwsVpc() *schema.Resource {
Computed: true,
},
"main_route_table_id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"tags": tagsSchema(),
},
}
@ -90,7 +95,6 @@ func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error {
// Turn on partial mode
d.Partial(true)
defer d.Partial(false)
if d.HasChange("enable_dns_hostnames") {
options := new(ec2.ModifyVpcAttribute)
@ -128,7 +132,8 @@ func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error {
d.SetPartial("tags")
}
return nil
d.Partial(false)
return resourceAwsVpcRead(d, meta)
}
func resourceAwsVpcDelete(d *schema.ResourceData, meta interface{}) error {
@ -181,6 +186,18 @@ func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
}
d.Set("enable_dns_hostnames", resp.EnableDnsHostnames)
// Get the main routing table for this VPC
filter := ec2.NewFilter()
filter.Add("association.main", "true")
filter.Add("vpc-id", d.Id())
routeResp, err := ec2conn.DescribeRouteTables(nil, filter)
if err != nil {
return err
}
if v := routeResp.RouteTables; len(v) > 0 {
d.Set("main_route_table_id", v[0].RouteTableId)
}
return nil
}

View File

@ -47,4 +47,5 @@ The following attributes are exported:
* `cidr_block` - The CIDR block of the VPC
* `enable_dns_support` - Whether or not the VPC has DNS support
* `enable_dns_hostnames` - Whether or not the VPC has DNS hostname support
* `main_route_table_id` - The ID of the main route table associated with
this VPC.