workspace
local vs remote workspace
Ah nice 👌 you’ve already moved your state to Terraform Cloud and created workspaces there. That changes things a bit. Let me clear it up for you:
🔹 Local Workspaces vs Terraform Cloud Workspaces
Local workspaces (
terraform workspace new dev) are just state-isolated folders on your machine.Terraform Cloud workspaces are completely separate — each workspace has its own remote state, runs, and variables managed in the Cloud UI.
👉 Once you are using Terraform Cloud workspaces, you don’t need to create local workspaces with terraform workspace new.
🔹 How it works with Terraform Cloud
You define the backend in your
main.tf:terraform { backend "remote" { organization = "my-org" workspaces { name = "dev" } } }This ties your local project to the
devworkspace in Terraform Cloud.
If you want to use
prodinstead, you update the backend block:terraform { backend "remote" { organization = "my-org" workspaces { name = "prod" } } }Or, you can use:
terraform { backend "remote" { organization = "my-org" workspaces { prefix = "myapp-" } } }Then
terraform init+terraform workspace select myapp-devwill map to the Cloud workspace.Each Terraform Cloud workspace has its own:
Remote state
Variables (set in UI or via CLI vars)
Runs history
Execution mode (local or remote)
🔹 TL;DR for your case
Since you already created
devandprodin Terraform Cloud, ✅ you don’t needterraform workspace new dev/prodlocally.You just select the workspace in Terraform Cloud (via backend config or
terraform workspace selectif you’re using aprefixsetup).
Do you want me to show you the best practice way to configure backend with prefix, so you can switch between dev / prod without editing your main.tf every time?
Last updated