mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Return empty string when input empty S3 bucket policy
Before: "" -> "Error parsing JSON: unexpected end of JSON input" After: "" -> ""
This commit is contained in:
parent
38078fbfb8
commit
8d1292d608
@ -907,7 +907,7 @@ func removeNil(data map[string]interface{}) map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func normalizeJson(jsonString interface{}) string {
|
func normalizeJson(jsonString interface{}) string {
|
||||||
if jsonString == nil {
|
if jsonString == nil || jsonString == "" {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
var j interface{}
|
var j interface{}
|
||||||
|
@ -69,6 +69,14 @@ func TestAccAWSS3Bucket_Policy(t *testing.T) {
|
|||||||
"aws_s3_bucket.bucket", ""),
|
"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)
|
`, 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 {
|
func testAccAWSS3BucketConfigWithVersioning(randInt int) string {
|
||||||
return fmt.Sprintf(`
|
return fmt.Sprintf(`
|
||||||
resource "aws_s3_bucket" "bucket" {
|
resource "aws_s3_bucket" "bucket" {
|
||||||
|
Loading…
Reference in New Issue
Block a user