Merge pull request #3777 from hashicorp/pr-3751

provider/aws: fix panic with SNS topic policy if omitted
This commit is contained in:
Clint 2015-11-10 16:45:42 -06:00
commit 68764e6def
1 changed files with 5 additions and 2 deletions

View File

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