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

internal/keyvaluetags: New Go package for consistently managing resource tags #10018

Merged
merged 5 commits into from
Sep 30, 2019

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Sep 6, 2019

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Release note for CHANGELOG:

NONE

The keyvaluetags package is designed to provide a consistent interface for handling AWS resource key-value tags. Many of the AWS Go SDK services, implement their own Go struct with Key and Value fields (e.g. athena.Tag) while others simply use a map (e.g. map[string]string). These inconsistent implementations and numerous Go types makes the process of correctly working with each of the services a tedius, previously copy-paste-modify process.

This package instead implements a single KeyValueTags type, which covers all key-value handling logic such as merging tags and ignoring keys via functions on the single type. Much of the code associated with tagging operations can be code generated. Adding tagging abilities for new AWS services now only requires a few lines of code.

Output from acceptance testing:

--- PASS: TestAccAWSAthenaWorkGroup_disappears (13.62s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_ResultConfiguration_EncryptionConfiguration_SseS3 (20.73s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_BytesScannedCutoffPerQuery (25.21s)
--- PASS: TestAccAWSAthenaWorkGroup_Description (29.82s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_EnforceWorkgroupConfiguration (31.01s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_PublishCloudWatchMetricsEnabled (36.91s)
--- PASS: TestAccAWSAthenaWorkGroup_Tags (40.80s)
--- PASS: TestAccAWSAthenaWorkGroup_State (43.45s)
--- PASS: TestAccAWSAthenaWorkGroup_basic (57.10s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_ResultConfiguration_EncryptionConfiguration_Kms (59.79s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_ResultConfiguration_OutputLocation (60.00s)

@bflad bflad added technical-debt Addresses areas of the codebase that need refactoring or redesign. provider Pertains to the provider itself, rather than any interaction with AWS. labels Sep 6, 2019
@ghost ghost added size/XXL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Sep 6, 2019
@ewbankkit
Copy link
Contributor

SO happy for this 😃 😃 😃.
Will there be support for services (S3 springs to mind) where there are no operation to explictly update tags, just operations to put and delete the full set of tags on a resource?

@bflad
Copy link
Contributor Author

bflad commented Sep 6, 2019

Will there be support for services (S3 springs to mind) where there are no operation to explictly update tags, just operations to put and delete the full set of tags on a resource?

I think once we get through a first pass of covering most of the "regular" services, we can look to migrate the very customized services into this new package as well. If nothing else, to at least use the same underlying functionality of the package, even if the wrapping code is not automatically generated. 😄

Output from acceptance testing:

```
--- PASS: TestAccAWSAthenaWorkGroup_disappears (13.62s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_ResultConfiguration_EncryptionConfiguration_SseS3 (20.73s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_BytesScannedCutoffPerQuery (25.21s)
--- PASS: TestAccAWSAthenaWorkGroup_Description (29.82s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_EnforceWorkgroupConfiguration (31.01s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_PublishCloudWatchMetricsEnabled (36.91s)
--- PASS: TestAccAWSAthenaWorkGroup_Tags (40.80s)
--- PASS: TestAccAWSAthenaWorkGroup_State (43.45s)
--- PASS: TestAccAWSAthenaWorkGroup_basic (57.10s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_ResultConfiguration_EncryptionConfiguration_Kms (59.79s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_ResultConfiguration_OutputLocation (60.00s)
```
… error

Output from acceptance testing:

```
--- PASS: TestAccAWSAthenaWorkGroup_disappears (10.58s)
--- PASS: TestAccAWSAthenaWorkGroup_basic (14.71s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_ResultConfiguration_EncryptionConfiguration_SseS3 (14.98s)
--- PASS: TestAccAWSAthenaWorkGroup_Description (22.34s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_PublishCloudWatchMetricsEnabled (22.90s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_BytesScannedCutoffPerQuery (22.92s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_EnforceWorkgroupConfiguration (23.13s)
--- PASS: TestAccAWSAthenaWorkGroup_State (32.09s)
--- PASS: TestAccAWSAthenaWorkGroup_Tags (32.27s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_ResultConfiguration_EncryptionConfiguration_Kms (54.86s)
--- PASS: TestAccAWSAthenaWorkGroup_Configuration_ResultConfiguration_OutputLocation (54.90s)
```
@bflad
Copy link
Contributor Author

bflad commented Sep 28, 2019

Rebased against master to resolve merge conflict with GNUmakefile

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@bflad bflad added this to the v2.31.0 milestone Sep 30, 2019
@bflad
Copy link
Contributor Author

bflad commented Sep 30, 2019

My immediate plan after merging:

  • Implement EKS tagging and document the process in the Contributing Guide
  • Fix the CloudHSMv2 multiple tags issue
  • Switchover aws_vpc and aws_subnet resources to prepare for a planned proof of concept

@bflad bflad merged commit 3e61dea into master Sep 30, 2019
@bflad bflad deleted the f-keyvaluetags branch September 30, 2019 14:52
@ghost
Copy link

ghost commented Oct 3, 2019

This has been released in version 2.31.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 or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Nov 1, 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 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
provider Pertains to the provider itself, rather than any interaction with AWS. size/XXL Managed by automation to categorize the size of a PR. technical-debt Addresses areas of the codebase that need refactoring or redesign. 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.

5 participants