From c519ea74c523f3375e785590d543e4bdcfa86467 Mon Sep 17 00:00:00 2001 From: James Nugent Date: Mon, 4 Jan 2016 16:14:30 -0500 Subject: [PATCH] provider/aws: Don't set NatGatewayId with no value This fixes create aws_route_table resources in regions which do not support the NAT Gateway yet (e.g. eu-central) - unless a value is explicitly set in which case the API call will fail until such time as NAT Gateway is supported. Fixes #4499. --- builtin/providers/aws/resource_aws_route_table.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_route_table.go b/builtin/providers/aws/resource_aws_route_table.go index 752b771fe..6ba2153e6 100644 --- a/builtin/providers/aws/resource_aws_route_table.go +++ b/builtin/providers/aws/resource_aws_route_table.go @@ -290,12 +290,15 @@ func resourceAwsRouteTableUpdate(d *schema.ResourceData, meta interface{}) error RouteTableId: aws.String(d.Id()), DestinationCidrBlock: aws.String(m["cidr_block"].(string)), GatewayId: aws.String(m["gateway_id"].(string)), - NatGatewayId: aws.String(m["nat_gateway_id"].(string)), InstanceId: aws.String(m["instance_id"].(string)), VpcPeeringConnectionId: aws.String(m["vpc_peering_connection_id"].(string)), NetworkInterfaceId: aws.String(m["network_interface_id"].(string)), } + if m["nat_gateway_id"].(string) != "" { + opts.NatGatewayId = aws.String(m["nat_gateway_id"].(string)) + } + log.Printf("[INFO] Creating route for %s: %#v", d.Id(), opts) if _, err := conn.CreateRoute(&opts); err != nil { return err