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

Add support for metadata on s3 objects #1945

Merged
merged 13 commits into from
Jul 24, 2019

Conversation

jocgir
Copy link
Contributor

@jocgir jocgir commented Oct 17, 2017

No description provided.

@Ninir Ninir added the enhancement Requests to existing resources that expand the functionality or scope. label Oct 18, 2017
@radeksimko radeksimko added the size/M Managed by automation to categorize the size of a PR. label Nov 15, 2017
@bflad bflad added the service/s3 Issues and PRs that pertain to the s3 service. label Jan 28, 2018
@julienduchesne julienduchesne deleted the support-metadata-on-s3-objects branch February 26, 2018 11:53
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Apr 7, 2018
@scott2449
Copy link

Not sure how the pipeline works here. How long before this will hit the release version?

@jocgir
Copy link
Contributor Author

jocgir commented May 24, 2018

Not sure neither. One of our PR have been merged within minutes while another took months. We just cross our fingers and wait.

@scott2449
Copy link

We have some Hashicorp licenses/support @ Dow Jones. Let me poke them from that direction.

@jocgir
Copy link
Contributor Author

jocgir commented May 24, 2018

Cool, thanks!

@julienduchesne julienduchesne force-pushed the support-metadata-on-s3-objects branch from c0e0ff6 to d878a5f Compare July 4, 2018 12:19
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Jul 4, 2018
@julienduchesne
Copy link
Contributor

This PR would be ready to merge. We have been using it for a while now. Added an acceptance test.

make testacc TESTARGS='-run=TestAccAWSS3BucketObject_metadata'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -run=TestAccAWSS3BucketObject_metadata -timeout 120m
?       github.com/terraform-providers/terraform-provider-aws   [no test files]
=== RUN   TestAccAWSS3BucketObject_metadata
--- PASS: TestAccAWSS3BucketObject_metadata (28.45s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       28.461s

@ghost ghost added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. documentation Introduces or discusses updates to documentation. labels Jan 18, 2019
@julienduchesne julienduchesne force-pushed the support-metadata-on-s3-objects branch from f1fffa3 to b78710a Compare January 18, 2019 16:28
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.

Hi @jocgir 👋 Thanks for submitting this. Please see the below initial feedback and let us know if you have any questions or do not have time to implement the items.

@@ -77,6 +77,12 @@ func resourceAwsS3BucketObject() *schema.Resource {
Optional: true,
},

"metadata": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add the Elem configuration for this new TypeMap attribute?

Elem: schema.Schema{Type: schema.TypeString},

meta[key] = &valueStr
}

putInput.Metadata = meta
Copy link
Contributor

Choose a reason for hiding this comment

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

The above conversion logic can be removed with using the existing stringMapToPointers helper function:

Suggested change
putInput.Metadata = meta
putInput.Metadata = stringMapToPointers(v.(map[string]interface{}))

@@ -299,6 +315,15 @@ func resourceAwsS3BucketObjectRead(d *schema.ResourceData, meta interface{}) err
d.Set("content_encoding", resp.ContentEncoding)
d.Set("content_language", resp.ContentLanguage)
d.Set("content_type", resp.ContentType)
metadata := pointersMapToStringList(resp.Metadata)

// AWS Go SDK capitalizes metadata, this is a workaround. https://github.com/aws/aws-sdk-go/issues/445
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for this context!

aws/resource_aws_s3_bucket_object.go Outdated Show resolved Hide resolved
aws/resource_aws_s3_bucket_object_test.go Outdated Show resolved Hide resolved
CheckDestroy: testAccCheckAWSS3BucketObjectDestroy,
Steps: []resource.TestStep{
{
PreConfig: func() {},
Copy link
Contributor

Choose a reason for hiding this comment

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

Extraneous PreConfig can be removed 👍

website/docs/r/s3_bucket_object.html.markdown Outdated Show resolved Hide resolved
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSS3BucketObjectDestroy,
Steps: []resource.TestStep{
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the new attribute does not include ForceNew: true, this test should include a second TestStep that updates the metadata information.

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Mar 26, 2019
jocgir and others added 2 commits April 25, 2019 17:38
bflad and others added 3 commits April 25, 2019 18:08
Co-Authored-By: jocgir <jocgir@users.noreply.github.com>
Co-Authored-By: jocgir <jocgir@users.noreply.github.com>
@aeschright aeschright requested a review from a team June 28, 2019 18:17
@bflad bflad added this to the v2.21.0 milestone Jul 24, 2019
@bflad
Copy link
Contributor

bflad commented Jul 24, 2019

Hi folks 👋 Since we haven't seen anything in awhile regarding the remaining feedback items, they were finished up in a followup commit. Adding the additional test steps showed that metadata updates were not occurring correctly, so that is also fixed.

Output from acceptance testing:

--- PASS: TestAccAWSS3BucketObject_contentBase64 (30.69s)
--- PASS: TestAccAWSS3BucketObject_content (31.18s)
--- PASS: TestAccAWSS3BucketObject_withContentCharacteristics (31.51s)
--- PASS: TestAccAWSS3BucketObject_empty (31.68s)
--- PASS: TestAccAWSS3BucketObject_sse (31.84s)
--- PASS: TestAccAWSS3BucketObject_source (32.12s)
--- PASS: TestAccAWSS3BucketObject_updates (50.09s)
--- PASS: TestAccAWSS3BucketObject_updatesWithVersioning (51.04s)
--- PASS: TestAccAWSS3BucketObject_kms (54.27s)
--- PASS: TestAccAWSS3BucketObject_metadata (69.32s)
--- PASS: TestAccAWSS3BucketObject_acl (72.38s)
--- PASS: TestAccAWSS3BucketObject_tags (89.73s)
--- PASS: TestAccAWSS3BucketObject_tagsLeadingSlash (90.66s)
--- PASS: TestAccAWSS3BucketObject_storageClass (107.45s)

@bflad bflad merged commit a3931ef into hashicorp:master Jul 24, 2019
bflad added a commit that referenced this pull request Jul 24, 2019
Reference: #1945 (review)

Output from acceptance testing:

```
--- PASS: TestAccAWSS3BucketObject_contentBase64 (30.69s)
--- PASS: TestAccAWSS3BucketObject_content (31.18s)
--- PASS: TestAccAWSS3BucketObject_withContentCharacteristics (31.51s)
--- PASS: TestAccAWSS3BucketObject_empty (31.68s)
--- PASS: TestAccAWSS3BucketObject_sse (31.84s)
--- PASS: TestAccAWSS3BucketObject_source (32.12s)
--- PASS: TestAccAWSS3BucketObject_updates (50.09s)
--- PASS: TestAccAWSS3BucketObject_updatesWithVersioning (51.04s)
--- PASS: TestAccAWSS3BucketObject_kms (54.27s)
--- PASS: TestAccAWSS3BucketObject_metadata (69.32s)
--- PASS: TestAccAWSS3BucketObject_acl (72.38s)
--- PASS: TestAccAWSS3BucketObject_tags (89.73s)
--- PASS: TestAccAWSS3BucketObject_tagsLeadingSlash (90.66s)
--- PASS: TestAccAWSS3BucketObject_storageClass (107.45s)
```
bflad added a commit that referenced this pull request Jul 24, 2019
@julienduchesne
Copy link
Contributor

Oh wow. Completely forgot about updating this PR for merge. Thanks for making the changes yourself and merging @bflad 🎉 ❤️

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Jul 24, 2019
@bflad
Copy link
Contributor

bflad commented Jul 26, 2019

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

For further feature requests, documentation updates, or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@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/M 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.

6 participants