TerraformVariable and TF_VAR_ environment variables


Best pratices say to use TerraformVariable to store secrets and pass them using TF_VAR_NAME: terraform-cdk/best-practices.mdx at main · hashicorp/terraform-cdk · GitHub

It seems to suggest that when the ID is “something”, the variable should be TF_VAR_something. However, it is namespaced by the stack as well as a hash, so it’s more something like TF_VAR_stack_something_567ADE.

Is that expected?

This can be fixed by setting excludeStackIdFromLogicalIds in cdktf.json.