What are best practices for Terraform state management?
⚡
Quick Answer
Store state in a remote backend (S3+DynamoDB, Terraform Cloud, Azure Blob) with locking and encryption, isolate state per environment/component, never commit state to Git, and use terraform state commands for surgical edits.
Detailed Answer
Remote state enables team collaboration; locking prevents concurrent applies from corrupting it; encryption protects the secrets it may contain. Splitting state (by environment and by blast radius) limits the impact of a bad apply and speeds plans. Workspaces or separate backends keep environments apart. Treat state as critical, backed-up infrastructure.
💡
Interview Tip
Mention state isolation by environment/blast radius — beyond just remote+lock, it shows scaling experience.
terraformstatebest-practices