From ccfe468e7d04cd32600641f2d2631b04ec776ec3 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 26248bac1204..25a599672d11 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-", m["cidr_block"].(string))) + } if v, ok := m["gateway_id"]; ok { buf.WriteString(fmt.Sprintf("%s-", v.(string)))