Interview Prep/Terraform/State Backends and Workspaces

Compare directories, workspaces and branches for environment separation.

IntermediateScenarioState Backends and Workspaces
Answer

Situation read → A design-review question.

What I'd do →

  1. Directories per environment: explicit, separate state and backend, best for prod isolation, some duplication.
  2. CLI workspaces: minimal duplication, same backend and credentials, easy mistakes.
  3. Branch per environment: drift between branches and painful merges; avoid.

Why → Production safety comes from separate credentials and state, and directories give you both.

Interview tip → Recommend directories plus shared modules, with workspaces only for ephemeral copies.

All Terraform questions Roadmap: Terraform in production

More on State Backends and Workspaces