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{
Type: schema.TypeString,
Optional: true,
ForceNew: false,
Computed: true,
StateFunc: func(v interface{}) string {
jsonb := []byte{}
if v != nil {
jsonb = []byte(v.(string))
if v == nil {
return ""
}
jsonb := []byte{}
buffer := new(bytes.Buffer)
if err := json.Compact(buffer, jsonb); err != nil {
log.Printf("[WARN] Error compacting JSON for Policy in SNS Topic")