provider/aws: fix panic when user_data receives nil from StateFunc

This commit is contained in:
Ryan Uber 2014-08-22 18:11:06 -07:00
parent 0317120866
commit e530eea226
1 changed files with 7 additions and 2 deletions

View File

@ -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 ""
}
},
},