cdktf: forExpressionForMap does not render correctly #3540
Labels
bug
Something isn't working
cdktf
confirmed
independently reproduced by an engineer on the team
priority/important-soon
High priority, to be worked on as part of our current release or the following one.
Expected Behavior
Based on the documentation, I would expect the follow code using
TerraformIterator
andforExpressionForMap
to render a correct expression.I would expect something akin to the following HCL:
or in JSON
Actual Behavior
The input map is not correctly rendered.
Steps to Reproduce
repro.ts
:npx ts-node repro.ts
Versions
Providers
N/A; issue with core cdktf
Gist
No response
Possible Solutions
terraform-cdk/packages/cdktf/lib/tfExpression.ts
Line 395 in 639b61a
This is supposed to be returning a resolved token as a string. However, it is returning the input object as-is and that gets
[object Object]
'd a few lines down:terraform-cdk/packages/cdktf/lib/tfExpression.ts
Line 402 in 639b61a
Workarounds
This isn't the most ideal but building the expression by hand is a workaround.
JSON.stringify
probably isn't a great way to get that map in, but that was the easiest I could find. The logic that seems to be used for other expression builders is locked away in the un-exportedTFExpression
class 😞.renderMap
is exported, however that implementation inserts newlines which is not desirable for this particular use case.Anything Else?
No response
References
No response
Help Wanted
Community Note
The text was updated successfully, but these errors were encountered: