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.
More on State Internals
What does the state file contain?BeginnerWhat is the difference between local and remote state?BeginnerHow do you configure the S3 backend?BeginnerWhat is state locking and why does it matter?IntermediateHow does S3-native locking work and how does it replace DynamoDB?AdvancedHow do you inspect resources in state?Beginner