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

resource/aws_cloudfront_distribution: Fix active_trusted_signers attribute for Terraform 0.12 #10013

Merged
merged 3 commits into from
Sep 6, 2019

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Sep 5, 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

Closes #8902

Release note for CHANGELOG:

* resource/aws_cloudfront_distribution: Support accessing `active_trusted_signers` attribute `items` in Terraform 0.12

This attribute implemented a legacy Terraform library (flatmap), which does not work with Terraform 0.12's data types and whose only usage was on this single attribute. This was missed during the Terraform 0.12 upgrade since there were no covering acceptance tests and the CloudFront setup itself is fairly esoteric (requires root AWS account login to manage CloudFront Keys).

The attribute now correctly implements (in the closest approximation) the standard Terraform Provider SDK types and methodology for saved nested object data to the Terraform state. The items subattribute list is now accessible again in Terraform 0.12. It does, however, unavoidably switch the root active_trusted_signers attribute to TypeList instead of TypeMap (which does not support map elements of different types in the current Terraform Provider SDK), so any potential references to nested attributes will need to be changed in user configurations, e.g.

Previously:

aws_cloudfront_distribution.example.active_trusted_signers.enabled

Now:

aws_cloudfront_distribution.example.active_trusted_signers.0.enabled

Output from acceptance testing:

--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_TrustedSigners (611.33s)

…tribute for Terraform 0.12

Reference: #8902

This attribute implemented a legacy Terraform library (`flatmap`), which does not work with Terraform 0.12's data types and whose only usage was on this single attribute. This was missed during the Terraform 0.12 upgrade since there were no covering acceptance tests and the CloudFront setup itself is fairly esoteric (requires root AWS account login to manage CloudFront Keys).

The attribute now correctly implements (in the closest approximation) the standard Terraform Provider SDK types and methodology for saved nested object data to the Terraform state. The `items` subattribute list is now accessible again in Terraform 0.12. It does, however, unavoidably switch the root `active_trusted_signers` attribute to `TypeList` instead of `TypeMap` (which does not support map elements of different types in the current Terraform Provider SDK), so any potential references to nested attributes will need to be changed in user configurations, e.g.

Previously:

```
aws_cloudfront_distribution.example.active_trusted_signers.enabled
```

Now:

```
aws_cloudfront_distribution.example.active_trusted_signers.0.enabled
```

Output from acceptance testing:

```
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_TrustedSigners (611.33s)
```
@bflad bflad added bug Addresses a defect in current functionality. service/cloudfront Issues and PRs that pertain to the cloudfront service. technical-debt Addresses areas of the codebase that need refactoring or redesign. labels Sep 5, 2019
@bflad bflad requested a review from a team September 5, 2019 19:50
@ghost ghost added size/L Managed by automation to categorize the size of a PR. dependencies Used to indicate dependency changes. documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Sep 5, 2019
…ctive_trusted_signers", ...) error

Output from acceptance testing:

```
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_TrustedSigners
```
@nywilken nywilken added this to the v2.28.0 milestone Sep 6, 2019
Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

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

LGTM 👍 👍

Is this something we should add a note to the changelog for?

Previously:
aws_cloudfront_distribution.example.active_trusted_signers.enabled
Now:
aws_cloudfront_distribution.example.active_trusted_signers.0.enabled

signer["key_pair_ids"] = aws.StringValueSlice(v.KeyPairIds.Items)
s = append(s, signer)
func flattenCloudfrontSigners(signers []*cloudfront.Signer) []interface{} {
result := make([]interface{}, 0, len(signers))
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

@bflad
Copy link
Contributor Author

bflad commented Sep 6, 2019

Is this something we should add a not to the changelog for?

Indeed! Definitely will call out this one.

@bflad bflad merged commit 268d49c into master Sep 6, 2019
@bflad bflad deleted the td-remove-flatmap branch September 6, 2019 16:43
bflad added a commit that referenced this pull request Sep 6, 2019
@ghost
Copy link

ghost commented Sep 12, 2019

This has been released in version 2.28.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!

bflad added a commit that referenced this pull request Sep 25, 2019
…lly for now, add test covering existing active_trusted_signers behavior

Reference: #8902
Reference: #10013
Reference: #10093

Temporarily keep the existing behavior for the only provider attribute using the legacy package so we can migrate to the standalone Terraform Plugin SDK from the github.com/hashicorp/terraform dependency in the future. Switching this attribute to not use the flatmap package will require state migration or deprecation.

Output from acceptance testing:

```
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_TrustedSigners (1351.69s)
```
@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
@anGie44 anGie44 restored the td-remove-flatmap branch July 24, 2020 21:53
@anGie44 anGie44 deleted the td-remove-flatmap branch July 24, 2020 23:08
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. dependencies Used to indicate dependency changes. documentation Introduces or discusses updates to documentation. service/cloudfront Issues and PRs that pertain to the cloudfront service. size/L 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.

resource/aws_cloudfront_distribution: Get rid of flatmap dependency
2 participants