Created
May 29, 2018 20:21
-
-
Save itsamenathan/c110df51dadd52d55933cbd57761144c to your computer and use it in GitHub Desktop.
Terraform workspace checking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
https://medium.com/@diogok/terraform-workspaces-and-locals-for-environment-separation-a5b88dd516f5