Closed fele-systems closed 1 month ago
Hi @fele-systems
Thanks for reporting this issue and taking the time to debug the code. We are lifting the restriction here #1714 for the cases where it's possible to compute the for-expr and this and many other cases will be possible.
The problem is that inside the content
block, partial evaluation is supported, and then not always things can be computed because they are incomplete.
Example:
generate_hcl "main.hcl" {
content {
list = {for v in local.something : tm_hcl_expression(v)}
}
}
The tm_hcl_expression()
needs to know v
to spill out the code but it depends on unknown data, so this is uncomputable and will continue to be the case.
Hello. Thanks for explaining and thanks for the fixes too.
Describe the bug Sometimes, terramate will disallow the usage of 'for' expression inside tm_dynamic blocks. It's possible to trick terramate using some shenanigans. More info commented inside the code bellow.
To Reproduce The following is a generate _hcl block which will fail
Expected behavior The above should've generate the following code, but it fails and no code is generated:
Log Output
Environment:
Additional context I did some debugging in the code, and found that the error message comes from the partialEvalForExpr function declared inside partial_eval.go. Apparently it's missing a
c.Eval(forExpr)
like the others partialEval functions. Still, I don't understand why there's a terramate variables check in the first place and if it's safe to just remove it.