Interview Prep/Terraform/State Internals

Workspaces versus separate directories per environment: which do you choose?

AdvancedConceptState Internals
Answer

For real environments we use separate directories (or repos) with their own state, backend and credentials, since prod and dev need different accounts, access and often different shapes. CLI workspaces suit short-lived copies of identical stacks (feature or PR environments). Their downsides: it is easy to run against the wrong workspace, and code branches on terraform.workspace.

All Terraform questions Roadmap: Terraform in production

More on State Internals