Open doctor-house opened 9 months ago
Hi @doctor-house 👋
Please excuse the late reply! I was able to confirm the bug you're running into and it seems like JSII (the underlying library translating between the CDK supported languages) has problems with Terraform functions that return a boolean value (which is modeled as an IResolvable
as there are no boolean tokens in the CDKs). This makes this problem hard to quickly fix.
However, in the meantime, it is possible to work around this by using strings containing raw expressions (e.g. "${some_function()}"
). Below is a C# example for the function you encountered the bug for.
var str = new TerraformVariable(this, "str", new TerraformVariableConfig
{
Type = "string",
Default = "foo"
});
var fooBar = new TerraformLocal(this, "foo_bar", $"${{strcontains({str.Fqn}, \"bar\")}}");
This synthesizes the following Terraform JSON for the local:
// ...
"locals": {
"foo_bar": "${strcontains(var.str, \"bar\")}"
},
// ...
Expected Behavior
There should be no error when using
Fn.Strcontains()
Actual Behavior
cdktf synth
produces the following error:Steps to Reproduce
cdktf init --template=csharp
to make a new projectMainStack.cs
cdktf synth
to see the error.Versions
language: csharp cdktf-cli: 0.20.0 node: v18.12.0 cdktf: 0.20.0 constructs: 10.0.25 jsii: 1.93.0 terraform: 1.2.6 arch: x64 os: win32 10.0.22621 dotnet: 6.0.320
Providers
┌┐ ││ └┘
Gist
No response
Possible Solutions
No response
Workarounds
No response
Anything Else?
No response
References
No response
Help Wanted
Community Note