Open Jimwoodward opened 4 years ago
This sounds like a fun project. Can anyone think of a reason that Hashicorp/TFC wouldn't allow it?
I would be willing to do the work to implement this if Hashicorp is interested.
We also have a ton of workspaces and organizing them by environment (rather than app name) is far more appealing.
I think it would be also very interesting to make name/prefix optional and take whatever the user sets as TF_WORKSPACE as the workspace name.
This would allow to follow any custom convention without relying on prefix/suffix limitations.
We've started generating our backend configuration that is git ignored, then simply use terraform init -backend-config=./backend_config.hcl
. It will require a wrapper script of some sort, but that's not a huge issue.
Current Terraform Version
Use-cases
The end goal of this request is to be able to use
terraform plan
,terraform apply
, andterraform init
, with one set of terraform code, that has one remote backend configured to work across multiple workspaces, where the workspace's names share a common suffix. Example workspace names would bedevelopment-vpc
,staging-vpc
, andproduction-vpc
.Attempted Solutions
The present attempted solution was to use a variable in the remote backend, but that is not supported. Here is an example of what that would look like:
This is obviously not allowed since variables are not allowed in backends. The result of running
terraform init
with this though is:Proposal
The change we would like to see to support our use case is like the currently supported
prefix
option (https://www.terraform.io/docs/backends/types/remote.html#prefix), but instead of a common prefix, a common suffix.The current prefix method looks like:
The suffix method would look like:
Additional
We have over 1500 workspaces in Terraform Cloud. They all follow the naming convention of
<environment>-workspace-name-here
, and we have automation built around this naming convention. Changing our workspace names to follow a convention where the shared, static aspect of their name comes first, and the dynamic environment aspect of them comes second, is unfortunately out of the question for us due to the level of effort.