From 87dd5c5bd077f67631a0103ea8db3d16fb2c9055 Mon Sep 17 00:00:00 2001 From: Tomas Doran Date: Wed, 4 Nov 2015 04:23:13 -0800 Subject: [PATCH] Fix panic I see when upgrading to 0.6.6 Check if the policy is nil or not before type casting it --- builtin/providers/aws/resource_aws_sns_topic.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_sns_topic.go b/builtin/providers/aws/resource_aws_sns_topic.go index 6a1c46590..26e98a9b1 100644 --- a/builtin/providers/aws/resource_aws_sns_topic.go +++ b/builtin/providers/aws/resource_aws_sns_topic.go @@ -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")