Terraform Drift Detection Cheat Sheet

Plans, state comparisons, and remediation

Last Updated: November 21, 2025

Focus Areas

Focus
Compare remote state to config with `terraform plan`
Refresh state before every drift check

Commands & Queries

terraform init
Load providers and modules
terraform plan -detailed-exitcode
Detect drift via exit codes
terraform apply --auto-approve
Sync infrastructure after review

Summary

Make drift detection part of PR workflows and document manual fixes.

💡 Pro Tip: Schedule `terraform plan` runs against the latest state and gate merges on zero drift.
← Back to DevOps & Cloud | Browse all categories | View all cheat sheets