Hello,
Can someone guide whats the definition i have to use in my backend.tf to switch between the terraform cloud workspaces.
Its working with 1 static workspace name (ex: Dev). I want this to be switched for other 2 environments for which i have created 2 TFC workspaces named Staging and Prod.
terraform {
cloud {
organization = “my-org”
hostname = “app.terraform.io”
workspaces {
name = “Dev” #How to switch between staging and prod
}
}
}
I have tried below but not worked out…
- using var. env (Looks like there is a limitation not to use variables inside the block)
2.defined TF_VAR_workspace_name Environment variable inside the Dev,staging and prod workspaces with values to each… I am trying to use this in AZUredevops yaml pipeline… Still no luck.
Can someone help here?