Different workspaces are needed to crated and selected for different environment deployment, in bash I could do the hack
terraform workspace select $env_name || terraform workspace new $env_name
that will execute second command if first fails
My question is how can I run this in terragrunt before hooks?
#root/terragrunt.hcl
terraform {
before_hook "workspace" {
commands = ["plan", "apply", "destroy"]
execute = ["terraform", "workspace", "select", local.environment]
}
Seems terragrunt is not able to recognise the "||" sign
I haven't been able to get it to work simply by using execute parameters, however a workaround is creating a bash file called something like workspace.sh like so:
Then within the terragrunt config: