Compare directories, workspaces and branches for environment separation.
IntermediateScenarioState Backends and Workspaces
Answer
Situation read → A design-review question.
What I'd do →
- Directories per environment: explicit, separate state and backend, best for prod isolation, some duplication.
- CLI workspaces: minimal duplication, same backend and credentials, easy mistakes.
- 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.
More on State Backends and Workspaces
Two engineers keep overwriting each other's changes because state is local. What's the fix?BeginnerSet up a production-grade S3 backend. What do you configure for locking?IntermediateHow do you harden the S3 bucket that holds Terraform state?IntermediateWho creates the state bucket itself, given Terraform needs it to exist before `init`?IntermediateA laptop apply and a CI apply start at the same time. What stops state corruption?IntermediateWhen are Terraform workspaces appropriate?Beginner