Skip to content

Instantly share code, notes, and snippets.

@itsamenathan
Created May 29, 2018 20:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsamenathan/c110df51dadd52d55933cbd57761144c to your computer and use it in GitHub Desktop.
Save itsamenathan/c110df51dadd52d55933cbd57761144c to your computer and use it in GitHub Desktop.
Terraform workspace checking
variable "supported_workspaces" {
default = ["dev", "beta", "prod"]
}
resource "null_resource" "is_workspace_supported" {
count = "${contains(var.supported_workspaces, terraform.workspace) ? 0 : 1}"
"\n\n!!!! ERROR !!!!\nYou are getting this error because you are trying to use an unsupported workspace. \nSupported workspaces are: [${join(", ", var.supported_workspaces)}]. You are currently using the \"${terraform.workspace}\" workspace. \nPlease see the README file for information on how to configure a workspace." = true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment