Skip to content

Commit

Permalink
Merge pull request #9442 from jjulien/s3_object_all_sses3_etag
Browse files Browse the repository at this point in the history
Allow S3 objects to use etag and SSE-S3 encryption
  • Loading branch information
bflad authored Aug 20, 2019
2 parents 55522e3 + 46a710b commit 7344ca2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aws/resource_aws_s3_bucket_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func resourceAwsS3BucketObject() *schema.Resource {
// See http://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonResponseHeaders.html
Optional: true,
Computed: true,
ConflictsWith: []string{"kms_key_id", "server_side_encryption"},
ConflictsWith: []string{"kms_key_id"},
},

"version_id": {
Expand Down
40 changes: 40 additions & 0 deletions aws/resource_aws_s3_bucket_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,30 @@ func TestAccAWSS3BucketObject_content(t *testing.T) {
})
}

func TestAccAWSS3BucketObject_etagEncryption(t *testing.T) {
var obj s3.GetObjectOutput
resourceName := "aws_s3_bucket_object.object"
rInt := acctest.RandInt()
source := testAccAWSS3BucketObjectCreateTempFile(t, "{anything will do }")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSS3BucketObjectDestroy,
Steps: []resource.TestStep{
{
PreConfig: func() {},
Config: testAccAWSS3BucketObjectEtagEncryption(rInt, source),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketObjectExists(resourceName, &obj),
testAccCheckAWSS3BucketObjectBody(&obj, "{anything will do }"),
resource.TestCheckResourceAttr(resourceName, "etag", "7b006ff4d70f68cc65061acf2f802e6f"),
),
},
},
})
}

func TestAccAWSS3BucketObject_contentBase64(t *testing.T) {
var obj s3.GetObjectOutput
resourceName := "aws_s3_bucket_object.object"
Expand Down Expand Up @@ -951,6 +975,22 @@ resource "aws_s3_bucket_object" "object" {
`, randInt, content)
}

func testAccAWSS3BucketObjectEtagEncryption(randInt int, source string) string {
return fmt.Sprintf(`
resource "aws_s3_bucket" "object_bucket" {
bucket = "tf-object-test-bucket-%d"
}
resource "aws_s3_bucket_object" "object" {
bucket = "${aws_s3_bucket.object_bucket.bucket}"
key = "test-key"
source = "%s"
server_side_encryption = "AES256"
etag = "${filemd5("%s")}"
}
`, randInt, source, source)
}

func testAccAWSS3BucketObjectConfigContentBase64(randInt int, contentBase64 string) string {
return fmt.Sprintf(`
resource "aws_s3_bucket" "object_bucket" {
Expand Down

0 comments on commit 7344ca2

Please sign in to comment.