Skip to content

Commit

Permalink
Handle JSON parsing error in the ReadFunc for the policy document.
Browse files Browse the repository at this point in the history
Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
  • Loading branch information
kwilczynski committed Sep 22, 2016
1 parent a35695a commit 15d33c7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions builtin/providers/aws/resource_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
Expand Down Expand Up @@ -471,10 +472,11 @@ func resourceAwsS3BucketRead(d *schema.ResourceData, meta interface{}) error {
return err
}
} else {
policy, _ := normalizeJsonString(*v)
if err := d.Set("policy", policy); err != nil {
return err
policy, err := normalizeJsonString(*v)
if err != nil {
return errwrap.Wrapf("policy contains an invalid JSON: {{err}}", err)
}
d.Set("policy", policy)
}
}
}
Expand Down

0 comments on commit 15d33c7

Please sign in to comment.