From 2d5745328b51b82571252579b699eecdccbad90f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 13 May 2016 12:33:05 -0700 Subject: [PATCH] providers/aws: import main route table association --- .../providers/aws/import_aws_route_table.go | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/import_aws_route_table.go b/builtin/providers/aws/import_aws_route_table.go index c6e694773..a226f7578 100644 --- a/builtin/providers/aws/import_aws_route_table.go +++ b/builtin/providers/aws/import_aws_route_table.go @@ -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 }