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]
|
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
|
{
|
||||||
subResource := resourceAwsRoute()
|
// Construct the routes
|
||||||
for _, route := range table.Routes {
|
subResource := resourceAwsRoute()
|
||||||
// Ignore the local/default route
|
for _, route := range table.Routes {
|
||||||
if route.GatewayId != nil && *route.GatewayId == "local" {
|
// Ignore the local/default route
|
||||||
continue
|
if route.GatewayId != nil && *route.GatewayId == "local" {
|
||||||
}
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Minimal data for route
|
// Minimal data for route
|
||||||
d := subResource.Data(nil)
|
d := subResource.Data(nil)
|
||||||
d.SetType("aws_route")
|
d.SetType("aws_route")
|
||||||
d.Set("route_table_id", id)
|
d.Set("route_table_id", id)
|
||||||
d.Set("destination_cidr_block", route.DestinationCidrBlock)
|
d.Set("destination_cidr_block", route.DestinationCidrBlock)
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue