providers/aws: route tables import assocations

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

View File

@ -27,9 +27,11 @@ func resourceAwsRouteTableImportState(
table := resp.RouteTables[0] table := resp.RouteTables[0]
// Start building our results // Start building our results
results := make([]*schema.ResourceData, 1, 1+len(table.Routes)) results := make([]*schema.ResourceData, 1,
1+len(table.Associations)+len(table.Routes))
results[0] = d results[0] = d
{
// Construct the routes // Construct the routes
subResource := resourceAwsRoute() subResource := resourceAwsRoute()
for _, route := range table.Routes { for _, route := range table.Routes {
@ -46,6 +48,25 @@ func resourceAwsRouteTableImportState(
d.SetId(routeIDHash(d, route)) d.SetId(routeIDHash(d, route))
results = append(results, d) results = append(results, d)
} }
}
{
// Construct the associations
subResource := resourceAwsRouteTableAssociation()
for _, assoc := range table.Associations {
if *assoc.Main {
// Ignore
continue
}
// Minimal data for route
d := subResource.Data(nil)
d.SetType("aws_route_table_association")
d.Set("route_table_id", assoc.RouteTableId)
d.SetId(*assoc.RouteTableAssociationId)
results = append(results, d)
}
}
return results, nil return results, nil
} }