workspace

chevron-rightlocal vs remote workspacehashtag

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

  1. You define the backend in your main.tf:

    terraform {
      backend "remote" {
        organization = "my-org"
    
        workspaces {
          name = "dev"
        }
      }
    }
    • This ties your local project to the dev workspace in Terraform Cloud.

  2. If you want to use prod instead, 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-dev will map to the Cloud workspace.

  3. 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 dev and prod in Terraform Cloud, ✅ you don’t need terraform workspace new dev/prod locally.

  • You just select the workspace in Terraform Cloud (via backend config or terraform workspace select if you’re using a prefix setup).


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