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

Suppport -backend-config and/or optional script dir with terraform workspace commands #22555

Open
benfortuna opened this issue Aug 22, 2019 · 0 comments

Comments

@benfortuna
Copy link

benfortuna commented Aug 22, 2019

Current Terraform Version

$ terraform -v
Terraform v0.12.0

Use-cases

Currently I can run terraform init -backend-config=<path> [dir] that allows me to separate the local state/backend config vars from the terraform provisioning scripts (including partial backend config).

However I cannot use terraform workspaces with this configuration as (I believe) it currently requires the state/backend config vars to be in the same directory as the terraform scripts. If I do use terraform workspace new it will give the error:

Backend reinitialization required..
Reason: Unsetting the previously set backend..

Attempted Solutions

I've explore available environment variables but there doesn't seem to be any global way to set additional backend-config. Also I think the optional directory for terraform scripts should be explicitly added to the command itself.

Other commands such as terraform state allow state to exist in another directory via: terraform state <subcommand> -state <path>, however this option is already used to copy old state to a new workspace, and it also may not work considering workspaces are using multiple state files.

Many commands support optional directory for terraform scripts, which may be easiest to implement for the workspace commands: e.g. terraform plan <scripts_dir>.

Proposal

Add the -backend-config and/or optional scripts directory to terraform workspace commands to allow separation of state/config: terraform workspace new -backend-config <path> [dir]

References

@benfortuna benfortuna changed the title Suppport -backend-config with terraform workspace commands Suppport -backend-config and/or optional script dir with terraform workspace commands Aug 22, 2019
@hashibot hashibot added cli v0.12 Issues (primarily bugs) reported against v0.12 releases and removed v0.12 Issues (primarily bugs) reported against v0.12 releases labels Aug 22, 2019
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