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

r/aws_s3_bucket_object: Allow empty object #7544

Merged
merged 4 commits into from
Jul 18, 2019
Merged

r/aws_s3_bucket_object: Allow empty object #7544

merged 4 commits into from
Jul 18, 2019

Conversation

stefansundin
Copy link
Contributor

@stefansundin stefansundin commented Feb 14, 2019

Changes proposed in this pull request:

  • Allow empty S3 objects.

I haven't written a test for this since I am not sure it requires one. I have compiled and tested it live, with both content = "" and without source, content, and content_base64 altogether.

I recently wanted to be able to create empty S3 objects, to use them with website_redirect. There is no point in putting any data in those objects.

Currently I am using:

resource "aws_s3_bucket_object" "login" {
  bucket           = "${aws_s3_bucket.bucket.bucket}"
  key              = "login"
  content          = "dummy"
  website_redirect = "https://accounts.example.com/login"
  acl              = "public-read"
}

An empty object like this can also be created with the awscli:

aws s3api put-object --bucket example.com --key login --website-redirect-location https://accounts.example.com/login

Let me know if you think a new test is necessary, and I will write one. Thank you!

… the natural configuration for website_redirect, since those objects do not require any content.
@ghost ghost added size/XS Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/s3 Issues and PRs that pertain to the s3 service. labels Feb 14, 2019
@ewbankkit
Copy link
Contributor

@stefansundin Acceptance tests always appreciated 😄 .

@ghost ghost added size/S Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. and removed size/XS Managed by automation to categorize the size of a PR. labels Feb 14, 2019
@stefansundin
Copy link
Contributor Author

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSS3BucketObject_empty'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSS3BucketObject_empty -timeout 120m
=== RUN   TestAccAWSS3BucketObject_empty
=== PAUSE TestAccAWSS3BucketObject_empty
=== CONT  TestAccAWSS3BucketObject_empty
--- PASS: TestAccAWSS3BucketObject_empty (14.24s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	14.282s

Let me know if I should change anything else!

@stefansundin
Copy link
Contributor Author

I think this one is ready to be merged. :)

@stefansundin
Copy link
Contributor Author

@bflad @ewbankkit I think this one is ready for review.

@aeschright aeschright requested a review from a team June 25, 2019 22:12
@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label Jul 18, 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.

Sorry for the delayed review, LGTM. 🚀

--- PASS: TestAccAWSS3BucketObject_acl (68.12s)
--- PASS: TestAccAWSS3BucketObject_content (28.25s)
--- PASS: TestAccAWSS3BucketObject_contentBase64 (27.65s)
--- PASS: TestAccAWSS3BucketObject_empty (29.19s)
--- PASS: TestAccAWSS3BucketObject_kms (52.87s)
--- PASS: TestAccAWSS3BucketObject_source (27.28s)
--- PASS: TestAccAWSS3BucketObject_sse (27.85s)
--- PASS: TestAccAWSS3BucketObject_storageClass (104.25s)
--- PASS: TestAccAWSS3BucketObject_tags (84.20s)
--- PASS: TestAccAWSS3BucketObject_tagsLeadingSlash (87.44s)
--- PASS: TestAccAWSS3BucketObject_updates (48.88s)
--- PASS: TestAccAWSS3BucketObject_updatesWithVersioning (49.12s)
--- PASS: TestAccAWSS3BucketObject_withContentCharacteristics (29.28s)

@bflad bflad added this to the v2.20.0 milestone Jul 18, 2019
@bflad bflad merged commit 3b36a21 into hashicorp:master Jul 18, 2019
bflad added a commit that referenced this pull request Jul 18, 2019
@ghost
Copy link

ghost commented Nov 2, 2019

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 Nov 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/s3 Issues and PRs that pertain to the s3 service. size/S 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.

3 participants