State management
⏱ ~3-min readAceMark GuideWhat this topic is really about
Workspaces enable a single Terraform configuration to manage multiple distinct state files, making it easy to isolate environments like development and production. Option A is incorrect because using multiple workspaces is optional, as Terraform automatically uses a single default workspace if none are created.
Configuring an S3 backend with a DynamoDB table allows teams to store the Terraform state file remotely in S3 while using DynamoDB to prevent concurrent runs via state locking. This setup is designed for state management rather than hosting the Terraform binary or storing application-level database records.
See the mechanism
Terraform stores state locally in a 'terraform.tfstate' file by default, but teams should use remote backends like Amazon S3 for secure, shared access and state locking. A diagram for this topic isn't available yet — the worked example below walks the same reasoning step by step.
An exam-style question, fully explained
Terraform state is stored:
- Identify what the question tests: Terraform state is stored:.
- Terraform stores state locally in a 'terraform.tfstate' file by default, but teams should use remote backends like Amazon S3 for secure, shared access and state locking.
- Storing state only locally is risky for teams because it can easily lead to conflicts and overwritten changes.
Traps the examiner sets
- Storing state only locally is risky for teams because it can easily lead to conflicts and overwritten changes.
- Option A is incorrect because using multiple workspaces is optional, as Terraform automatically uses a single default workspace if none are created.
Test your recall
Answer each from memory — you'll see instantly whether you're right and why.
Run a focused 10-question mini-mock on State management and see it stick.
Practice more of this topic →