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

Don't create new S3 object versions when updating just tags or ACL #7138

Merged
merged 1 commit into from
Jan 15, 2019

Conversation

ewbankkit
Copy link
Contributor

Fixes #7130 and #5841.

Acceptance tests:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSS3BucketObject_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -parallel 20 -run=TestAccAWSS3BucketObject_ -timeout 120m
=== RUN   TestAccAWSS3BucketObject_source
=== PAUSE TestAccAWSS3BucketObject_source
=== RUN   TestAccAWSS3BucketObject_content
=== PAUSE TestAccAWSS3BucketObject_content
=== RUN   TestAccAWSS3BucketObject_contentBase64
=== PAUSE TestAccAWSS3BucketObject_contentBase64
=== RUN   TestAccAWSS3BucketObject_withContentCharacteristics
=== PAUSE TestAccAWSS3BucketObject_withContentCharacteristics
=== RUN   TestAccAWSS3BucketObject_updates
=== PAUSE TestAccAWSS3BucketObject_updates
=== RUN   TestAccAWSS3BucketObject_updatesWithVersioning
=== PAUSE TestAccAWSS3BucketObject_updatesWithVersioning
=== RUN   TestAccAWSS3BucketObject_kms
=== PAUSE TestAccAWSS3BucketObject_kms
=== RUN   TestAccAWSS3BucketObject_sse
=== PAUSE TestAccAWSS3BucketObject_sse
=== RUN   TestAccAWSS3BucketObject_acl
=== PAUSE TestAccAWSS3BucketObject_acl
=== RUN   TestAccAWSS3BucketObject_storageClass
=== PAUSE TestAccAWSS3BucketObject_storageClass
=== RUN   TestAccAWSS3BucketObject_tags
=== PAUSE TestAccAWSS3BucketObject_tags
=== CONT  TestAccAWSS3BucketObject_source
=== CONT  TestAccAWSS3BucketObject_tags
=== CONT  TestAccAWSS3BucketObject_storageClass
=== CONT  TestAccAWSS3BucketObject_acl
=== CONT  TestAccAWSS3BucketObject_sse
=== CONT  TestAccAWSS3BucketObject_kms
=== CONT  TestAccAWSS3BucketObject_updatesWithVersioning
=== CONT  TestAccAWSS3BucketObject_updates
=== CONT  TestAccAWSS3BucketObject_withContentCharacteristics
=== CONT  TestAccAWSS3BucketObject_contentBase64
=== CONT  TestAccAWSS3BucketObject_content
--- PASS: TestAccAWSS3BucketObject_source (29.47s)
--- PASS: TestAccAWSS3BucketObject_withContentCharacteristics (29.54s)
--- PASS: TestAccAWSS3BucketObject_content (29.55s)
--- PASS: TestAccAWSS3BucketObject_sse (29.66s)
--- PASS: TestAccAWSS3BucketObject_contentBase64 (29.90s)
--- PASS: TestAccAWSS3BucketObject_updatesWithVersioning (49.96s)
--- PASS: TestAccAWSS3BucketObject_updates (50.80s)
--- PASS: TestAccAWSS3BucketObject_kms (53.10s)
--- PASS: TestAccAWSS3BucketObject_acl (71.10s)
--- PASS: TestAccAWSS3BucketObject_storageClass (88.20s)
--- PASS: TestAccAWSS3BucketObject_tags (88.34s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	88.360s

@ghost ghost added size/XL Managed by automation to categorize the size of a PR. service/s3 Issues and PRs that pertain to the s3 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jan 14, 2019
return fmt.Errorf("Error putting object in S3 bucket (%s): %s", bucket, err)
}

// See https://forums.aws.amazon.com/thread.jspa?threadID=44003
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to set etag or version_id here. they're set in resourceAwsS3BucketObjectRead().

@ewbankkit
Copy link
Contributor Author

Acceptance tests after rebase:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSS3BucketObject_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -parallel 20 -run=TestAccAWSS3BucketObject_ -timeout 120m
=== RUN   TestAccAWSS3BucketObject_source
=== PAUSE TestAccAWSS3BucketObject_source
=== RUN   TestAccAWSS3BucketObject_content
=== PAUSE TestAccAWSS3BucketObject_content
=== RUN   TestAccAWSS3BucketObject_contentBase64
=== PAUSE TestAccAWSS3BucketObject_contentBase64
=== RUN   TestAccAWSS3BucketObject_withContentCharacteristics
=== PAUSE TestAccAWSS3BucketObject_withContentCharacteristics
=== RUN   TestAccAWSS3BucketObject_updates
=== PAUSE TestAccAWSS3BucketObject_updates
=== RUN   TestAccAWSS3BucketObject_updatesWithVersioning
=== PAUSE TestAccAWSS3BucketObject_updatesWithVersioning
=== RUN   TestAccAWSS3BucketObject_kms
=== PAUSE TestAccAWSS3BucketObject_kms
=== RUN   TestAccAWSS3BucketObject_sse
=== PAUSE TestAccAWSS3BucketObject_sse
=== RUN   TestAccAWSS3BucketObject_acl
=== PAUSE TestAccAWSS3BucketObject_acl
=== RUN   TestAccAWSS3BucketObject_storageClass
=== PAUSE TestAccAWSS3BucketObject_storageClass
=== RUN   TestAccAWSS3BucketObject_tags
=== PAUSE TestAccAWSS3BucketObject_tags
=== CONT  TestAccAWSS3BucketObject_source
=== CONT  TestAccAWSS3BucketObject_kms
=== CONT  TestAccAWSS3BucketObject_updatesWithVersioning
=== CONT  TestAccAWSS3BucketObject_updates
=== CONT  TestAccAWSS3BucketObject_storageClass
=== CONT  TestAccAWSS3BucketObject_tags
=== CONT  TestAccAWSS3BucketObject_acl
=== CONT  TestAccAWSS3BucketObject_sse
=== CONT  TestAccAWSS3BucketObject_contentBase64
=== CONT  TestAccAWSS3BucketObject_content
=== CONT  TestAccAWSS3BucketObject_withContentCharacteristics
--- PASS: TestAccAWSS3BucketObject_withContentCharacteristics (40.25s)
--- PASS: TestAccAWSS3BucketObject_sse (40.67s)
--- PASS: TestAccAWSS3BucketObject_source (42.87s)
--- PASS: TestAccAWSS3BucketObject_content (43.68s)
--- PASS: TestAccAWSS3BucketObject_contentBase64 (44.30s)
--- PASS: TestAccAWSS3BucketObject_updatesWithVersioning (63.31s)
--- PASS: TestAccAWSS3BucketObject_updates (66.03s)
--- PASS: TestAccAWSS3BucketObject_kms (67.21s)
--- PASS: TestAccAWSS3BucketObject_acl (87.81s)
--- PASS: TestAccAWSS3BucketObject_storageClass (105.57s)
--- PASS: TestAccAWSS3BucketObject_tags (106.97s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	121.964s

}

body = file
defer func() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't leak open file.

@@ -52,6 +52,57 @@ func setTagsS3(conn *s3.S3, d *schema.ResourceData) error {
return nil
}

func getTagsS3Object(conn *s3.S3, d *schema.ResourceData) error {
resp, err := retryOnAwsCode(s3.ErrCodeNoSuchKey, func() (interface{}, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes #5841.

@bflad bflad added the bug Addresses a defect in current functionality. label Jan 15, 2019
@bflad bflad added this to the v1.56.0 milestone Jan 15, 2019
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for this @ewbankkit, LGTM 🚀

--- PASS: TestAccAWSS3BucketObject_source (5.51s)
--- PASS: TestAccAWSS3BucketObject_content (5.89s)
--- PASS: TestAccAWSS3BucketObject_sse (5.95s)
--- PASS: TestAccAWSS3BucketObject_withContentCharacteristics (6.05s)
--- PASS: TestAccAWSS3BucketObject_contentBase64 (6.44s)
--- PASS: TestAccAWSS3BucketObject_updatesWithVersioning (8.96s)
--- PASS: TestAccAWSS3BucketObject_updates (9.16s)
--- PASS: TestAccAWSS3BucketObject_acl (12.66s)
--- PASS: TestAccAWSS3BucketObject_storageClass (15.05s)
--- PASS: TestAccAWSS3BucketObject_tags (15.49s)
--- PASS: TestAccAWSS3BucketObject_kms (24.37s)

@bflad bflad merged commit 0373bd1 into hashicorp:master Jan 15, 2019
bflad added a commit that referenced this pull request Jan 15, 2019
@ewbankkit ewbankkit deleted the issue-7130 branch January 15, 2019 20:34
@bflad
Copy link
Contributor

bflad commented Jan 16, 2019

This has been released in version 1.56.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/s3 Issues and PRs that pertain to the s3 service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

r/aws_s3_bucket_object: Updating just tags creates new object version
2 participants