Merge pull request #5474 from kjmkznr/skip-normalize-empty-policy

provider/aws: Fix error parsing JSON in S3 bucket policy
This commit is contained in:
Paul Stack 2016-03-07 18:53:51 +01:00
commit 46e4717428
2 changed files with 19 additions and 1 deletions

View File

@ -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{}

View File

@ -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", ""),
),
},
},
})
}
@ -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" {