provider/aws: main route table refresh handles VPC being gone [GH-1806]

This commit is contained in:
Mitchell Hashimoto 2015-05-05 18:07:22 -07:00
parent b085342274
commit 1a2bac7645
2 changed files with 7 additions and 5 deletions

View File

@ -118,6 +118,8 @@ BUG FIXES:
* provider/aws: Block devices can be encrypted [GH-1718]
* provider/aws: ASG health check grace period can be updated in-place [GH-1682]
* provider/aws: ELB security groups can be updated in-place [GH-1662]
* provider/aws: `aws_main_route_table_association` can be deleted
manually [GH-1806]
* provider/openstack: region config is not required [GH-1441]
* provider/openstack: `enable_dhcp` for networking subnet should be bool [GH-1741]
* provisioner/remote-exec: add random number to uploaded script path so

View File

@ -76,7 +76,7 @@ func resourceAwsMainRouteTableAssociationRead(d *schema.ResourceData, meta inter
return err
}
if *mainAssociation.RouteTableAssociationID != d.Id() {
if mainAssociation == nil || *mainAssociation.RouteTableAssociationID != d.Id() {
// It seems it doesn't exist anymore, so clear the ID
d.SetId("")
}
@ -135,6 +135,9 @@ func findMainRouteTableAssociation(conn *ec2.EC2, vpcId string) (*ec2.RouteTable
if err != nil {
return nil, err
}
if mainRouteTable == nil {
return nil, nil
}
for _, a := range mainRouteTable.Associations {
if *a.Main {
@ -159,10 +162,7 @@ func findMainRouteTable(conn *ec2.EC2, vpcId string) (*ec2.RouteTable, error) {
if err != nil {
return nil, err
} else if len(routeResp.RouteTables) != 1 {
return nil, fmt.Errorf(
"Expected to find a single main routing table for VPC: %s, but found %d",
vpcId,
len(routeResp.RouteTables))
return nil, nil
}
return routeResp.RouteTables[0], nil