I am trying to experiment with Terraform cdktf Python:
My mission consists of how really a condition is working with cdktf. So I tried to create outputs based on variable values, and it seems like the condition always returns false. Here is an example:
if test.string_value=="TNTN":
TerraformOutput(self, "alb_dns",
value=web_server_alb.dns_name
)
TerraformOutput(self, "instance_id",
value=instance_type
)
TerraformOutput(self, "test", value=test)
And I'm expecting that alb_dns
, instance_type
and product
are outputted when the condition is true.
Note that test variable is passed through environment variables (TF_VAR_test=TNTN
).
CDKTF does not provide any values of, e.g., resources at runtime, but it instead uses Tokens.
Therefore, you can not build conditionals on runtime values. You can only have conditionals on things known at compile time.