State Management for Terraforms
Terraform state is the file that records which real resources correspond to your configuration, and it is how Terraform knows what to change. Local state is fine for learning, but teams use remote backends with locking, such as S3 with DynamoDB or similar services. State operations like import, mv and rm adjust that record carefully when resources are renamed or adopted.
Stage: State · Part of the Terraform roadmap · Last reviewed 19 November 2026
What to learn in State Management
- Explain what the state file stores and why it must be protected
- Configure a remote backend with locking for shared work
- Import an existing resource into state with terraform import or an import block
- Rename a resource without recreation using terraform state mv or a moved block
- Detect and handle drift between state and real infrastructure
State Management interview questions
Why should state not be stored in Git?
State can contain sensitive values such as passwords and keys in plain text, and it changes on every apply, so Git commits would conflict and expose secrets. A remote backend with encryption, access control and locking is the safer place for shared state.
What is state locking?
Locking prevents two people or pipelines from running Terraform against the same state at once, which could corrupt it. When a run starts, the backend takes a lock and releases it at the end. Backends such as S3 with DynamoDB or HCP Terraform provide locking.
Where State Management fits in the Terraform roadmap
State Management belongs to the State stage (intermediate level), which takes about 12 hours. Source of truth.
Other units in this stage
Back to the full Terraform roadmap