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/cloudfront_distribution: re-introduce changes from #10013 to update active_trusted_signers attribute #14339

Merged
merged 10 commits into from
Jul 29, 2020

Conversation

anGie44
Copy link
Contributor

@anGie44 anGie44 commented Jul 24, 2020

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" or other comments that do not add relevant new information or questions, 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

Output from acceptance testing:

--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyOriginID (3.83s)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyDomainName (3.87s)
--- PASS: TestAccAWSCloudFrontDistribution_disappears (193.47s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn (201.01s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn_ConflictsWithCloudFrontDefaultCertificate (199.67s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (224.45s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Headers (239.53s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_TrustedSigners (240.74s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (242.14s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Headers (291.30s)
--- PASS: TestAccAWSCloudFrontDistribution_IsIPV6EnabledConfig (355.76s)
--- PASS: TestAccAWSCloudFrontDistribution_HTTP11Config (356.33s)
--- PASS: TestAccAWSCloudFrontDistribution_noOptionalItemsConfig (361.99s)
--- PASS: TestAccAWSCloudFrontDistribution_multiOrigin (362.33s)
--- PASS: TestAccAWSCloudFrontDistribution_RetainOnDelete (365.84s)
--- PASS: TestAccAWSCloudFrontDistribution_WaitForDeployment (381.25s)
--- PASS: TestAccAWSCloudFrontDistribution_orderedCacheBehavior (413.24s)
--- PASS: TestAccAWSCloudFrontDistribution_S3Origin (413.48s)
--- PASS: TestAccAWSCloudFrontDistribution_noCustomErrorResponseConfig (414.05s)
--- PASS: TestAccAWSCloudFrontDistribution_customOrigin (417.40s)
--- PASS: TestAccAWSCloudFrontDistribution_OriginGroups (403.50s)
--- PASS: TestAccAWSCloudFrontDistribution_Enabled (605.01s)
--- PASS: TestAccAWSCloudFrontDistribution_S3OriginWithTags (609.92s)

bflad and others added 4 commits July 24, 2020 18:07
…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)
```

(cherry picked from commit ebdc976)
…ctive_trusted_signers", ...) error

Output from acceptance testing:

```
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_TrustedSigners
```

(cherry picked from commit 1c2b6f4)
@anGie44 anGie44 requested a review from a team July 24, 2020 23:01
@ghost ghost added size/M Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/cloudfront Issues and PRs that pertain to the cloudfront service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jul 24, 2020
@anGie44 anGie44 added this to the v3.0.0 milestone Jul 24, 2020
@anGie44 anGie44 changed the title resource/cloudfront_distribution: cherry-pick #10013 resource/cloudfront_distribution: re-introduce changes from #10013 to update active_trusted_signers attribute Jul 24, 2020
@bflad
Copy link
Contributor

bflad commented Jul 27, 2020

Does Terraform 0.12 not have the state reading issue after upgrade? We originally pulled this out (#10093) because it appeared to require a state migration due the SDK difference handlers, even for configurations not using the actual attribute. An easier option to state migration (especially because the schema is huge for this resource), would be to remove the broken attribute and introduce a new one.

@anGie44
Copy link
Contributor Author

anGie44 commented Jul 27, 2020

Ready for re-review with re-named sub-field

Output of tests:

--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyOriginID (4.11s)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyDomainName (4.65s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Headers (181.21s)
--- PASS: TestAccAWSCloudFrontDistribution_disappears (190.42s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (204.57s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn (216.63s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn_ConflictsWithCloudFrontDefaultCertificate (215.46s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (304.61s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_TrustedSigners (304.62s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Headers (308.04s)
--- PASS: TestAccAWSCloudFrontDistribution_HTTP11Config (396.97s)
--- PASS: TestAccAWSCloudFrontDistribution_noCustomErrorResponseConfig (397.05s)
--- PASS: TestAccAWSCloudFrontDistribution_IsIPV6EnabledConfig (397.51s)
--- PASS: TestAccAWSCloudFrontDistribution_orderedCacheBehavior (397.67s)
--- PASS: TestAccAWSCloudFrontDistribution_RetainOnDelete (400.66s)
--- PASS: TestAccAWSCloudFrontDistribution_S3Origin (503.03s)
--- PASS: TestAccAWSCloudFrontDistribution_noOptionalItemsConfig (503.64s)
--- PASS: TestAccAWSCloudFrontDistribution_OriginGroups (393.25s)
--- PASS: TestAccAWSCloudFrontDistribution_customOrigin (504.97s)
--- PASS: TestAccAWSCloudFrontDistribution_multiOrigin (505.20s)
--- PASS: TestAccAWSCloudFrontDistribution_WaitForDeployment (513.18s)
--- PASS: TestAccAWSCloudFrontDistribution_Enabled (604.00s)
--- PASS: TestAccAWSCloudFrontDistribution_S3OriginWithTags (612.00s)

@bflad bflad self-assigned this Jul 27, 2020
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 for the update, @anGie44. I think this is on the right track -- just need to adjust the top level attribute name so core/SDK ignores the existing attribute state or deal with an awful state migration.

aws/resource_aws_cloudfront_distribution.go Outdated Show resolved Hide resolved
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. provider Pertains to the provider itself, rather than any interaction with AWS. and removed size/M Managed by automation to categorize the size of a PR. labels Jul 29, 2020
@anGie44 anGie44 force-pushed the td-cloudfront-distribution-flatmap branch from 4faef14 to d452680 Compare July 29, 2020 17:47
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.

Minor documentation suggestions, otherwise looks good to me once the acceptance testing passes. 👍

website/docs/guides/version-3-upgrade.html.md Outdated Show resolved Hide resolved
website/docs/guides/version-3-upgrade.html.md Outdated Show resolved Hide resolved
website/docs/r/cloudfront_distribution.html.markdown Outdated Show resolved Hide resolved
website/docs/r/cloudfront_distribution.html.markdown Outdated Show resolved Hide resolved
@anGie44
Copy link
Contributor Author

anGie44 commented Jul 29, 2020

Output of acceptance tests:

--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyOriginID (4.19s)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyDomainName (5.34s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_TrustedSigners (197.22s)
--- PASS: TestAccAWSCloudFrontDistribution_disappears (203.25s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Headers (204.28s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Headers (204.74s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn (223.86s)
--- PASS: TestAccAWSCloudFrontDistribution_ViewerCertificate_AcmCertificateArn_ConflictsWithCloudFrontDefaultCertificate (270.55s)
--- PASS: TestAccAWSCloudFrontDistribution_OrderedCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (276.07s)
--- PASS: TestAccAWSCloudFrontDistribution_DefaultCacheBehavior_ForwardedValues_Cookies_WhitelistedNames (278.62s)
--- PASS: TestAccAWSCloudFrontDistribution_HTTP11Config (396.36s)
--- PASS: TestAccAWSCloudFrontDistribution_orderedCacheBehavior (397.58s)
--- PASS: TestAccAWSCloudFrontDistribution_multiOrigin (402.42s)
--- PASS: TestAccAWSCloudFrontDistribution_customOrigin (402.78s)
--- PASS: TestAccAWSCloudFrontDistribution_RetainOnDelete (406.46s)
--- PASS: TestAccAWSCloudFrontDistribution_IsIPV6EnabledConfig (456.08s)
--- PASS: TestAccAWSCloudFrontDistribution_S3Origin (460.70s)
--- PASS: TestAccAWSCloudFrontDistribution_noOptionalItemsConfig (461.51s)
--- PASS: TestAccAWSCloudFrontDistribution_noCustomErrorResponseConfig (464.30s)
--- PASS: TestAccAWSCloudFrontDistribution_WaitForDeployment (472.92s)
--- PASS: TestAccAWSCloudFrontDistribution_OriginGroups (424.15s)
--- PASS: TestAccAWSCloudFrontDistribution_S3OriginWithTags (672.08s)
--- PASS: TestAccAWSCloudFrontDistribution_Enabled (674.12s)

@anGie44 anGie44 merged commit b168604 into master Jul 29, 2020
@anGie44 anGie44 deleted the td-cloudfront-distribution-flatmap branch July 29, 2020 21:16
anGie44 added a commit that referenced this pull request Jul 29, 2020
@ghost
Copy link

ghost commented Jul 31, 2020

This has been released in version 3.0.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 Aug 29, 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 Aug 29, 2020
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. provider Pertains to the provider itself, rather than any interaction with AWS. service/cloudfront Issues and PRs that pertain to the cloudfront 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.

resource/aws_cloudfront_distribution: Get rid of flatmap dependency
2 participants