State Management
This section explains how Terraform state is stored, locked, recovered, and protected.
What This Covers
- Local vs remote state usage
- S3 native locking configuration
- Backup and recovery with versioning
- Security and handling of sensitive data
Topics
- Local vs Remote State - Where state lives and why
- State Locking - S3 native locking setup and behavior
- State Lock Errors - What to do when lock acquisition fails
- Backup and Recovery - Version history and restore workflow
- Security Considerations - Protecting state files and access
Best Practices
- Never edit state manually. Use
terraform statecommands instead. - Keep bootstrap state safe.
infra/bootstrap/terraform.tfstateis critical. - Monitor lock duration to catch stuck operations early.
- Review state changes with
terraform planbeforeapply.