terraform-tfe-cloud-infrastructure-automation icon indicating copy to clipboard operation
terraform-tfe-cloud-infrastructure-automation copied to clipboard

Support for Terraform Cloud Workspace prefix

Open six8 opened this issue 3 years ago • 1 comments

Have a question? Please checkout our Slack Community or visit our Slack Archive.

Slack Community

Describe the Feature

To have terraform cloud automatically find workspaces to use with terraform workspace on the CLI, you configure it with a prefix:

terraform {
  backend "remote" {
    hostname = "app.terraform.io"
    organization = "company"

    workspaces {
      prefix = "my-app-"
    }
  }
}

See https://www.terraform.io/docs/language/settings/backends/remote.html#workspaces

terraform-tfe-cloud-infrastructure-automation puts the environment as a prefix. For example ue2. In order for terraform to find the workspaces by prefix, the environment would have to be used:

terraform {
  backend "remote" {
    hostname = "app.terraform.io"
    organization = "company"

    workspaces {
      prefix = "ue2-"
    }
  }
}

Project name as a prefix seems like a more expected prefix to support this behavior.

Expected Behavior

Workspace pattern is {project}-{stage}-{env} instead of {env}-{stage}-{project}. Essentially a reversed order -- least specific to most specific.

Use Case

To be able to use terraform workspace select to select a workspace by prefix.

Describe Ideal Solution

That the template used to set the workspace name is configurable.

Alternatives Considered

Using the env (ex ue2-) as a prefix. This doesn't work well because multiple, unrelated projects are on the same environment.

six8 avatar Nov 05 '21 01:11 six8