Skip to content

Commit

Permalink
Merge pull request #5474 from kjmkznr/skip-normalize-empty-policy
Browse files Browse the repository at this point in the history
provider/aws: Fix error parsing JSON in S3 bucket policy
  • Loading branch information
stack72 committed Mar 7, 2016
2 parents 122e9ac + 8d1292d commit 46e4717
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion builtin/providers/aws/resource_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ func removeNil(data map[string]interface{}) map[string]interface{} {
}

func normalizeJson(jsonString interface{}) string {
if jsonString == nil {
if jsonString == nil || jsonString == "" {
return ""
}
var j interface{}
Expand Down
18 changes: 18 additions & 0 deletions builtin/providers/aws/resource_aws_s3_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ func TestAccAWSS3Bucket_Policy(t *testing.T) {
"aws_s3_bucket.bucket", ""),
),
},
resource.TestStep{
Config: testAccAWSS3BucketConfigWithEmptyPolicy(rInt),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketExists("aws_s3_bucket.bucket"),
testAccCheckAWSS3BucketPolicy(
"aws_s3_bucket.bucket", ""),
),
},
},
})
}
Expand Down Expand Up @@ -724,6 +732,16 @@ resource "aws_s3_bucket" "bucket" {
`, randInt)
}

func testAccAWSS3BucketConfigWithEmptyPolicy(randInt int) string {
return fmt.Sprintf(`
resource "aws_s3_bucket" "bucket" {
bucket = "tf-test-bucket-%d"
acl = "public-read"
policy = ""
}
`, randInt)
}

func testAccAWSS3BucketConfigWithVersioning(randInt int) string {
return fmt.Sprintf(`
resource "aws_s3_bucket" "bucket" {
Expand Down

0 comments on commit 46e4717

Please sign in to comment.