providers/aws: import main route table association

This commit is contained in:
Mitchell Hashimoto 2016-05-13 12:33:05 -07:00
parent ab7b5dab2d
commit 2d5745328b
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
1 changed files with 21 additions and 1 deletions

View File

@ -28,7 +28,7 @@ func resourceAwsRouteTableImportState(
// Start building our results
results := make([]*schema.ResourceData, 1,
1+len(table.Associations)+len(table.Routes))
2+len(table.Associations)+len(table.Routes))
results[0] = d
{
@ -68,5 +68,25 @@ func resourceAwsRouteTableImportState(
}
}
{
// Construct the main associations. We could do this above but
// I keep this as a separate section since it is a separate resource.
subResource := resourceAwsMainRouteTableAssociation()
for _, assoc := range table.Associations {
if !*assoc.Main {
// Ignore
continue
}
// Minimal data for route
d := subResource.Data(nil)
d.SetType("aws_main_route_table_association")
d.Set("route_table_id", id)
d.Set("vpc_id", table.VpcId)
d.SetId(*assoc.RouteTableAssociationId)
results = append(results, d)
}
}
return results, nil
}