Fix panic I see when upgrading to 0.6.6

Check if the policy is nil or not before type casting it
This commit is contained in:
Tomas Doran 2015-11-04 04:23:13 -08:00
parent 9e9d4b2c72
commit 87dd5c5bd0
1 changed files with 4 additions and 1 deletions

View File

@ -47,7 +47,10 @@ func resourceAwsSnsTopic() *schema.Resource {
ForceNew: false,
Computed: true,
StateFunc: func(v interface{}) string {
jsonb := []byte(v.(string))
jsonb := []byte{}
if v != nil {
jsonb = []byte(v.(string))
}
buffer := new(bytes.Buffer)
if err := json.Compact(buffer, jsonb); err != nil {
log.Printf("[WARN] Error compacting JSON for Policy in SNS Topic")