diff --git a/resource_aws_instance.go b/resource_aws_instance.go
index <HASH>..<HASH> 100644
--- a/resource_aws_instance.go
+++ b/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 ""
+					}
 				},
 			},
provider/aws: fix panic when user_data receives nil from StateFunc