-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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: Get rid of flatmap dependency #8902
Comments
In Terraform 0.12 I would expect Terraform Core to be picky about values for this argument being exactly lists of strings, and so this would be appearing in the rest of the configuration as a map with the keys Probably in 0.11 this tricked the interpolator into converting this structure into a list of maps, because it only had the flatmap keys to work from, but the new protocol shims will see that this is a map and will serialize it as one so Terraform 0.12 will not be so easily fooled. Changing this to be (essentially) Leaving it as a map of string using flatmap-style keys -- either by hand-writing some simpler, more specialized code to generate it just for this case, or by copying the |
…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) ```
Pull request submitted: #10013 |
|
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! |
…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) ```
For now, this will move the |
…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)
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! |
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! |
As part of some preparation work for SDK decoupling I found this provider imports a legacy
flatmap
package - this isn't the way we plan to represent data in the SDK in the future anymore and it would be awesome if we could reduce the "core surface" exposed to providers by removing this dependency/import.The CloudFront Distribution resource apparently uses this for "flattening" SDK struct into a map here
https://github.com/terraform-providers/terraform-provider-aws/blob/b13ffce6248b6eadda3cd9ffd1664ac1aafe5f39/aws/cloudfront_distribution_configuration_structure.go#L1100-L1116
the affected field
active_trusted_signers
isTypeMap
https://github.com/terraform-providers/terraform-provider-aws/blob/b13ffce6248b6eadda3cd9ffd1664ac1aafe5f39/aws/resource_aws_cloudfront_distribution.go#L697-L700
which makes me doubt whether this actually ever worked - there isn't any test to prove it and I don't think we have much successful history of using TypeMap for nested structures.
I suppose the easiest way to resolve this would be migrate the schema to
TypeList
&MaxItems: 1
?The text was updated successfully, but these errors were encountered: