-
Notifications
You must be signed in to change notification settings - Fork 459
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
feat(lib): Add DynamicListTerraformIterator with support for lists or sets with objects that have properties that are only known at apply time #3273
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the approach overall and to my knowledge it looks good 👍 There are a few things missing for the overall picture from my point of view, let me know what you think:
- Documentation section about this (detailing the use-case & usage)
- Hcl2cdk needs to be made aware of this, ideally we would detect dynamic blocks / for_each being used from a complex list and then add the correct fromComplexList invocation. This will allow us to remove yet another escape hatch 🎉
eadbbb9
to
b5f96a5
Compare
122e792
to
942012f
Compare
9ae9829
to
adb801c
Compare
Merging even though C# example fails on the |
I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Problem
Terraform does not support iterating over lists without turning them into a set first. Sets that contain computed values need to be applied using
-target
in order for Terraform to know about these values before a plan is made. Using-target
and applying changes in two passes is not desirable. However, there’s a workaround by turning them into maps which is described below.Workaround by using Maps
A workaround for this case is to turn the set of objects into a map with keys that are based on arguments that are known during the plan stage. This is done for example in the HCL docs snippet for the
aws_acm_certificate_validation
resource:In the snippet above, the set of objects stored in
domain_validation_options
is converted into a map with thedomain_name
of each object as the key.If one instead tries to directly use
domain_validation_options
, the following error is printed (hinting at using-target
, as described in the problem section above):Solution
Allow the user to pass the attribute name to be used as the key in the map and convert the set/list into a map using a for expression.
Closes #2178
Related to #2001, #1393, #430 (some already closed with workarounds)