Repository navigation
fix: keep references in partly-known collections; expand for_each over locals with apply-time values - #290
Closed
ezaz-khan-apex wants to merge 1 commit into
Conversation
…r locals with apply-time values
1. A list or object literal holding one apply-time value (a resource attribute,
a module output) was serialized with that element as null, which reads as an
explicit null and loses the reference. Each such element now carries the same
{"__attribute__": ...} marker a top-level reference gets; known siblings are
unchanged.
2. A for_each over a local whose keys are known but whose values hold apply-time
attributes was never expanded. Terraform expands it, since the keys are known.
Fixed in the trivy fork (cloud-custodian/trivy PR, pinned here from
ezaz-khan-apex/trivy until it lands).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Closed
1 of 2 tasks
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two cases where tfparse dropped information Terraform has:
null(Unknown elements of a list/object literal serialize as null, losing the reference #288). A partly-knownTupleConsExpr/ObjectConsExpris now converted element by element. An unknown element that is a reference gets the same{"__attribute__": …}marker a top-level reference already gets, and its known siblings are unchanged. Object keys must be literals; anything else keeps the previous conversion. A value that reaches the attribute through a local is still a single marker, as before.for_eachover a local with known keys but apply-time values was never expanded (for_each over a local with known keys but apply-time values is never expanded #289). The fix is in the trivy fork, fix: expand for_each over a local whose keys are known but values are not trivy#23.go.modpins that branch (ezaz-khan-apex/trivy) for now, so CI exercises it; please re-pin tocloud-custodian/trivyonce 🌱 Bump pytest-terraform from 0.6.1 to 0.6.4 #23 lands, as fix: resolve for_each and data references #285 did with 🌱 Bump black from 22.6.0 to 22.8.0 #22.Tests:
test_partial_collection_keeps_unknown_references(fixturepartial-collection-references) getsnullon 0.6.22.test_for_each_over_local_with_unknown_values(fixturefor-each-local-unknown-values) gets an unexpandednodeon 0.6.22.blackandflake8are clean.For context: on a ~2,100-root Terraform repo, the two fixes together expand 156 more
for_eachinstances, and no existing value changes.Closes #288
Closes #289
🤖 Generated with Claude Code