From e530eea2265848bc2bf88c7cce4371ebed5f3ee8 Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Fri, 22 Aug 2014 18:11:06 -0700 Subject: [PATCH] provider/aws: fix panic when user_data receives nil from StateFunc --- builtin/providers/aws/resource_aws_instance.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/resource_aws_instance.go b/builtin/providers/aws/resource_aws_instance.go index d911ad975..3427d44cd 100644 --- a/builtin/providers/aws/resource_aws_instance.go +++ b/builtin/providers/aws/resource_aws_instance.go @@ -88,8 +88,13 @@ func resourceAwsInstance() *schema.Resource { Optional: true, ForceNew: true, StateFunc: func(v interface{}) string { - hash := sha1.Sum([]byte(v.(string))) - return hex.EncodeToString(hash[:]) + switch v.(type) { + case string: + hash := sha1.Sum([]byte(v.(string))) + return hex.EncodeToString(hash[:]) + default: + return "" + } }, },