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

Support for Terraform Cloud Workspace prefix #7

Open
six8 opened this issue Nov 5, 2021 · 1 comment
Open

Support for Terraform Cloud Workspace prefix #7

six8 opened this issue Nov 5, 2021 · 1 comment

Comments

@six8
Copy link

six8 commented Nov 5, 2021

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
Copy link
Author

six8 commented Nov 5, 2021

The docs say:

Our convention is to name files by $env-$stage.yaml (e.g. ue2-testing.yaml), so for example an $env could be ue2 (for us-east-2) and the $stage might be testing. Workspace names are derived from the $env-$stage-$project, which looks like ue2-testing-eks.

But it looks like the workspace name is $config_file_name-$project. This means I can name the file $project-$env-$stage instead of $env-$stage and get the desired effect of a project prefix.

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

No branches or pull requests

1 participant