From f085ae65fa115d2e9707279a94e6441b154279f8 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 12 Jul 2014 17:12:41 -0700 Subject: [PATCH] providers/aws: fix issue where default route was being added --- .../providers/aws/resource_aws_route_table.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/builtin/providers/aws/resource_aws_route_table.go b/builtin/providers/aws/resource_aws_route_table.go index 12a0fffe1..7ba631903 100644 --- a/builtin/providers/aws/resource_aws_route_table.go +++ b/builtin/providers/aws/resource_aws_route_table.go @@ -110,12 +110,18 @@ func resource_aws_route_table_update( break } - // Append to the routes what we've done so far - resultRoutes = append(resultRoutes, map[string]string{ - "cidr_block": op.Route.DestinationCidrBlock, - "gateway_id": op.Route.GatewayId, - "instance_id": op.Route.InstanceId, - }) + // If we didn't delete the route, append it to the list of routes + // we have. + if op.Op != routeTableOpDelete { + resultMap := map[string]string{"cidr_block": op.Route.DestinationCidrBlock} + if op.Route.GatewayId != "" { + resultMap["gateway_id"] = op.Route.GatewayId + } else if op.Route.InstanceId != "" { + resultMap["instance_id"] = op.Route.InstanceId + } + + resultRoutes = append(resultRoutes, resultMap) + } } // Update our state with the settings