provider/aws: fix panic with SNS topic policy if omitted

This commit is contained in:
clint shryock 2015-11-05 15:25:04 -06:00
parent 87dd5c5bd0
commit 274781224e
1 changed files with 3 additions and 4 deletions

View File

@ -44,13 +44,12 @@ func resourceAwsSnsTopic() *schema.Resource {
"policy": &schema.Schema{ "policy": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: false,
Computed: true, Computed: true,
StateFunc: func(v interface{}) string { StateFunc: func(v interface{}) string {
jsonb := []byte{} if v == nil {
if v != nil { return ""
jsonb = []byte(v.(string))
} }
jsonb := []byte{}
buffer := new(bytes.Buffer) buffer := new(bytes.Buffer)
if err := json.Compact(buffer, jsonb); err != nil { if err := json.Compact(buffer, jsonb); err != nil {
log.Printf("[WARN] Error compacting JSON for Policy in SNS Topic") log.Printf("[WARN] Error compacting JSON for Policy in SNS Topic")