Lets suppose I have dev, uat and prod environment. I wan’t to have some modules to be deployed in the dev environment but not in other environment.
I want to put a condition based on the workspace I have but can’t figure it out how. Any recommendation would be appreciated.
I tried to use $(terraform.workspace)
to select ‘dev’ enviroment but wasn’t working.
count = $(terraform.workspace) == "dev" ? 1 : 0 and it says
which resulted in:
This character is not used within the language.
2
Answers
You don’t need to use
$
sign.There are two different styles and two different logics to write this condition.
Different Styles
terraform.workspace
is equal to "dev" then create one instance else zero instance.Another logic
terraform.workspace
is not equal to "dev" then create zero instance else one instance.