From 1caef3031bcd95e4b41fee38e74dbd1b61c89059 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Wed, 3 Jun 2015 13:14:43 -0500 Subject: [PATCH] provider/aws: fix panic when route has no cidr_block While cidr_block is required for static route creation, there are apparently cases (involving some combination of VPNs, Customer Gateways, and automatic route propogation) where the cidr_block can come back nil. This means we cannot assume it's there in the set hash calculation. --- 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 436feddc2..e85601c1f 100644 --- a/builtin/providers/aws/resource_aws_route_table.go +++ b/builtin/providers/aws/resource_aws_route_table.go @@ -361,7 +361,10 @@ func resourceAwsRouteTableDelete(d *schema.ResourceData, meta interface{}) error func resourceAwsRouteTableHash(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) - buf.WriteString(fmt.Sprintf("%s-", m["cidr_block"].(string))) + + if v, ok := m["cidr_block"]; ok { + buf.WriteString(fmt.Sprintf("%s-", v.(string))) + } if v, ok := m["gateway_id"]; ok { buf.WriteString(fmt.Sprintf("%s-", v.(string)))