You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an cdktf app with multiple environments and providers. The native terraform way to inject these values is by using a .tfvars file. Currently all values are stored in a single file as a single point of truth. This causes variable values that are not consumed in that stack to be flagged as undeclared.
The compact warning flag also appears to not decrease the verboseness of the warnings either?
another-example-prod-stack ╷
│ Warning: Value for undeclared variable
│
│ The root module does not declare a variable named "DEV_EXAMPLE_VARIABLE"
│ but a value was found in file
│ "/cdktf-undeclared-var-bug-replication/terraform.tfvars".
│ If you meant to use this value, add a "variable" block to the
│ configuration.
│
│ To silence these warnings, use TF_VAR_... environment variables to provide
│ certain "global" settings to all configurations in your organization. To
│ reduce the verbosity of these warnings, use the -compact-warnings option.
╵
╷
│ Warning: Value for undeclared variable
│
│ The root module does not declare a variable named "PROD_EXAMPLE_VARIABLE"
│ but a value was found in file
│ "./cdktf-undeclared-var-bug-replication/terraform.tfvars".
│ If you meant to use this value, add a "variable" block to the
│ configuration.
│
│ To silence these warnings, use TF_VAR_... environment variables to provide
│ certain "global" settings to all configurations in your organization. To
│ reduce the verbosity of these warnings, use the -compact-warnings option.
╵
╷
│ Warning: Values for undeclared variables
│
│ In addition to the other similar warnings shown, 1 other variable(s)
│ defined without being declared.
╵
Actual Behavior
There seems to be no way to suppress this warning even using the HCL approach of explicitly defining the variables in a .tf file. This feel like an anti-pattern in CDK TF as well, as I am declaring the variables in ts.
I assume using TF_VAR_ environment variables would resolve this, but AFAIK there is no elegant implementation in Multiplatform scenarios. I think this would involve running a prescript which would suitable permissions to set environment variables.
Using a .tfvars file per stack I suspect would also satisfy the error. Again this is not elegant as some secrets are not environment dependent so would be duplicated between files. Also not sure how scalable this is considering a stack per provider and environment.
Workarounds
No response
Anything Else?
No response
References
No response
Help Wanted
I'm interested in contributing a fix myself
Community Note
Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
If you are interested in working on this issue or have submitted a pull request, please leave a comment
The text was updated successfully, but these errors were encountered:
Expected Behavior
I have an cdktf app with multiple environments and providers. The native terraform way to inject these values is by using a .tfvars file. Currently all values are stored in a single file as a single point of truth. This causes variable values that are not consumed in that stack to be flagged as undeclared.
The compact warning flag also appears to not decrease the verboseness of the warnings either?
Actual Behavior
There seems to be no way to suppress this warning even using the HCL approach of explicitly defining the variables in a .tf file. This feel like an anti-pattern in CDK TF as well, as I am declaring the variables in ts.
Steps to Reproduce
I have created a minimal replication. https://github.com/AlastairMiller/cdktf-undeclared-var-bug-replication
Versions
language: typescript
cdktf-cli: 0.20.4
node: v20.11.0
cdktf: 0.20.4
constructs: 10.3.0
jsii: null
terraform: 1.7.4
Providers
N/A
Gist
No response
Possible Solutions
I assume using TF_VAR_ environment variables would resolve this, but AFAIK there is no elegant implementation in Multiplatform scenarios. I think this would involve running a prescript which would suitable permissions to set environment variables.
Using a .tfvars file per stack I suspect would also satisfy the error. Again this is not elegant as some secrets are not environment dependent so would be duplicated between files. Also not sure how scalable this is considering a stack per provider and environment.
Workarounds
No response
Anything Else?
No response
References
No response
Help Wanted
Community Note
The text was updated successfully, but these errors were encountered: