Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s3_bucket_object: Fix ETAG changes not forcing new #9579

Merged
merged 2 commits into from
Aug 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions aws/resource_aws_s3_bucket_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,52 @@ func TestAccAWSS3BucketObject_updates(t *testing.T) {
})
}

func TestAccAWSS3BucketObject_updateSameFile(t *testing.T) {
var originalObj, modifiedObj s3.GetObjectOutput
resourceName := "aws_s3_bucket_object.object"
rInt := acctest.RandInt()

startingData := "lane 8"
changingData := "chicane"

filename := testAccAWSS3BucketObjectCreateTempFile(t, startingData)
defer os.Remove(filename)

rewriteFile := func(*terraform.State) error {
if err := ioutil.WriteFile(filename, []byte(changingData), 0644); err != nil {
os.Remove(filename)
t.Fatal(err)
}
return nil
}

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSS3BucketObjectDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSS3BucketObjectConfig_updateable(rInt, false, filename),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketObjectExists(resourceName, &originalObj),
testAccCheckAWSS3BucketObjectBody(&originalObj, startingData),
resource.TestCheckResourceAttr(resourceName, "etag", "aa48b42f36a2652cbee40c30a5df7d25"),
rewriteFile,
),
ExpectNonEmptyPlan: true,
},
{
Config: testAccAWSS3BucketObjectConfig_updateable(rInt, false, filename),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketObjectExists(resourceName, &modifiedObj),
testAccCheckAWSS3BucketObjectBody(&modifiedObj, changingData),
resource.TestCheckResourceAttr(resourceName, "etag", "fafc05f8c4da0266a99154681ab86e8c"),
),
},
},
})
}

func TestAccAWSS3BucketObject_updatesWithVersioning(t *testing.T) {
var originalObj, modifiedObj s3.GetObjectOutput
resourceName := "aws_s3_bucket_object.object"
Expand Down