Skip to content

Instantly share code, notes, and snippets.

@glaracuente
Created September 9, 2019 20:04
Show Gist options
  • Save glaracuente/0dcba98553b3022369e243b87209c731 to your computer and use it in GitHub Desktop.
Save glaracuente/0dcba98553b3022369e243b87209c731 to your computer and use it in GitHub Desktop.
workspace_checker for 0.12, does NOT work with 0.11
locals {
invalid_workspace = contains(var.valid_workspaces, terraform.workspace) ? null : file(
"ERROR: You're running in the ${terraform.workspace} workspace which isn't valid for this project. You can set the workspace name by typing: terraform workspace select <name>. Valid workspaces for this project are: ${join(",", var.valid_workspaces)}",
)
}
variable "valid_workspaces" {
description = "List of valid workspaces for this project"
type = list(string)
}
resource "null_resource" "workspace_checker" {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment