providers/aws: route tables import assocations
This commit is contained in:
parent
a1035804d4
commit
ab7b5dab2d
|
@ -27,24 +27,45 @@ func resourceAwsRouteTableImportState(
|
|||
table := resp.RouteTables[0]
|
||||
|
||||
// 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
|
||||
|
||||
// Construct the routes
|
||||
subResource := resourceAwsRoute()
|
||||
for _, route := range table.Routes {
|
||||
// Ignore the local/default route
|
||||
if route.GatewayId != nil && *route.GatewayId == "local" {
|
||||
continue
|
||||
}
|
||||
{
|
||||
// Construct the routes
|
||||
subResource := resourceAwsRoute()
|
||||
for _, route := range table.Routes {
|
||||
// Ignore the local/default route
|
||||
if route.GatewayId != nil && *route.GatewayId == "local" {
|
||||
continue
|
||||
}
|
||||
|
||||
// Minimal data for route
|
||||
d := subResource.Data(nil)
|
||||
d.SetType("aws_route")
|
||||
d.Set("route_table_id", id)
|
||||
d.Set("destination_cidr_block", route.DestinationCidrBlock)
|
||||
d.SetId(routeIDHash(d, route))
|
||||
results = append(results, d)
|
||||
// Minimal data for route
|
||||
d := subResource.Data(nil)
|
||||
d.SetType("aws_route")
|
||||
d.Set("route_table_id", id)
|
||||
d.Set("destination_cidr_block", route.DestinationCidrBlock)
|
||||
d.SetId(routeIDHash(d, route))
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue