Skip to main content

Workspaces in Cloud

Imagine your Lego city is now being built by a whole team. If everyone keeps their own local blueprint drawer (state file), chaos happens with different versions, conflicting changes, and lost progress.

Terraform Cloud solves this by storing the state remotely in a secure, shared vault, so the whole team works from the same blueprint. On top of that, workspaces act like labeled drawers for environments (dev, staging, prod), ensuring changes stay organized.


Key Concepts

1. Remote State in Terraform Cloud

  • Definition: Terraform Cloud stores state files centrally, instead of locally.
  • Benefits:
    • Shared access for teams.
    • Automatic state locking to prevent conflicts.
    • Encrypted and backed up for security.
  • Workflow:
    • Push code → Terraform Cloud runs plan and apply.
    • State is updated in the Cloud, visible to all team members.

2. Workspaces in Terraform Cloud

  • Definition: Workspaces separate environments (dev, staging, prod) within Terraform Cloud.
  • Features:
    • Each workspace has its own state file.
    • Can be linked to different VCS branches.
    • Supports environment‑specific variables and secrets.
  • Example:
    • dev workspace → linked to dev branch.
    • staging workspace → linked to staging branch.
    • prod workspace → linked to main branch.

3. Collaboration Benefits

  • Consistency: Everyone works from the same state.
  • Safety: State locking prevents simultaneous conflicting changes.
  • Transparency: Run history shows who applied what, when.
  • Flexibility: Workspaces allow environment separation without duplicating code.

Hands‑On Lab / Demo

Lab: Remote State & Workspaces Setup

  1. Create a new workspace in Terraform Cloud.
  2. Connect it to a GitHub repo.
  3. Push Terraform code → Terraform Cloud automatically runs plan.
  4. Observe:
    • State file stored remotely.
    • Workspace linked to branch.
    • Team members can view logs and outputs.

Pro Tips & Best Practices

  • Always use remote state for team projects.
  • Organize workspaces by environment (dev, staging, prod).
  • Use workspace variables for environment‑specific settings.
  • Document workspace strategy in project README.
  • Review run history regularly for auditing.

Summary & Cheatsheet

  • Remote state = Shared, secure, locked state in Terraform Cloud.
  • Workspaces = Environment separation with unique state files.
  • Benefits: Collaboration, safety, transparency, flexibility.
Quick mnemonic: Cloud State = One Truth, Workspaces = Many Environments

The Hackers Notebook

Remote state and workspaces in Terraform Cloud are the foundation of team collaboration. Remote state ensures everyone works from the same blueprint, while workspaces keep environments organized and safe. Together, they eliminate chaos and bring order to multi‑team infrastructure projects.


Tips, Tricks, Roadmaps, Resources, Networking, Motivation, Guidance, and Cool Stuff ♥

Updated on Dec 31, 2025