Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make possible *.auto.tfvars in workspaces #20104

Open
voroniys opened this issue Jan 24, 2019 · 2 comments
Open

Make possible *.auto.tfvars in workspaces #20104

voroniys opened this issue Jan 24, 2019 · 2 comments

Comments

@voroniys
Copy link

Current Terraform Version

Terraform v0.11.11

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 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.

@next-jesusmanuelnavarro

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.

@next-jesusmanuelnavarro

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants