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 #571
As a result of the #1510 refactoring, it's easier to add support for local values 🎉
Previously, the type of reference in the expression determined whether it could be evaluated or not, so it's hard to support local values that might resolve to unsupportable named values in a step of evaluation. However, unsupported named values are now evaluated to unknown, so static local values are resolved to final values, and unsupported named values are resolved to unknown values.
Note that the internal implementation takes a different approach than Terraform. Terraform references state for resolving local values.
https://github.com/hashicorp/terraform/blob/v1.3.0/internal/terraform/evaluate.go#L334
TFLint cannot refer to the state, so it simply evaluates the local value's expression and recursively get
cty.Value
. Note that this implementation will fall into an infinite loop if the expression contains circular references. So we need a mechanism to detect circular references from the graph, just like Terraform.