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
When I create a workspace it is vary usefull to also have a possibility to load workspace related tfvars files, so it would be not needed to provide -var-file option
Attempted Solutions
At the moment -var-file needed each time, what is inconvinient and possibility for errors (choose wrong file).
Proposal
When workspace created create terraform.tfvars.d/<ws_name> directory in addition to terraform.tfstate.d/...
Than for terraform plan/apply look for *.auto.tfvars files also in this new terraform.tfvars.d/<ws_name> directory.
This is really "low hanging fruit" - it can be done quite easily, but will drastically improve usability of terraform workspaces.
The text was updated successfully, but these errors were encountered:
I also use the pattern of "linking" tfvars to workspaces.
In order to minimize the risk of errors, I always use the same command line: terraform apply -var-file="environment-variables/$(terraform workspace show).tfvars".
Then, $(terraform workspace show) expands to the currently selected workspace so when, say, on workspace "development" it will use environment-variables/development.tfvars but when workspace "production" is selected, the same command line will use environment-variables/production.tfvars instead.
But there's another interesting thing in your request: the tfvars.d/ part, since I'd find great if the var-file option (or something related), allowed for a full directory of *.tfvars files instead of a single one. In fact, I found about this while reviewing issues in case someone already requested it, prior to open a feature request myself.
But there's another interesting thing in your request: the tfvars.d/ part, since I'd find great if the var-file option (or something related), allowed for a full directory of *.tfvars files instead of a single one. In fact, I found about this while reviewing issues in case someone already requested it, prior to open a feature request myself.
I just opened #27569 requesting the ability to load a directory of *.tfvars files instead of just one.
Current Terraform Version
Use-cases
When I create a workspace it is vary usefull to also have a possibility to load workspace related tfvars files, so it would be not needed to provide -var-file option
Attempted Solutions
At the moment -var-file needed each time, what is inconvinient and possibility for errors (choose wrong file).
Proposal
When workspace created create
terraform.tfvars.d/<ws_name>
directory in addition toterraform.tfstate.d/...
Than for terraform plan/apply look for *.auto.tfvars files also in this new
terraform.tfvars.d/<ws_name>
directory.This is really "low hanging fruit" - it can be done quite easily, but will drastically improve usability of terraform workspaces.
The text was updated successfully, but these errors were encountered: