Prompt
infrastructure as code drift detection
Latest observation
Nov 24, 2026
OpenAI APIWeb search: off
Infrastructure as Code (IaC) drift detection is the process of identifying differences between:
- the desired state defined in code/configuration
- the actual state of infrastructure running in cloud/on-prem
If something is changed manually in the console, via CLI, or by another automation tool, that can create drift.
Why it matters
Drift can cause:
- security gaps
- outages or misconfigurations
- failed deployments
- compliance issues
- “works in code, not in reality” problems
Common examples
- Someone changes an AWS security group rule by hand
- A VM size is modified outside Terraform
- A Kubernetes deployment is patched manually
- A database parameter is altered in the portal
How drift detection works
Typical approaches include:
- Compare state vs live infrastructure
- e.g. Terraform compares its state file and remote resources
- Periodic scans
- run on a schedule to detect changes
- Policy/compliance checks
- verify resource config against rules
- Event-driven detection
- trigger on cloud change events
Tools
- Terraform:
terraform plancan reveal drift - AWS Config
- Azure Policy
- Google Cloud Asset Inventory / Config Connector
- Pulumi refresh
- CloudFormation drift detection
- Kubernetes diff tools like Argo CD / Flux
Best practices
- Avoid manual changes in production
- Use CI/CD for all infra updates
- Run drift checks regularly
- Alert on drift and review it quickly
- Reconcile by either:
- updating code to match approved changes, or
- reverting the manual change
Simple Terraform example
terraform plan
If the live environment differs from the Terraform configuration, the plan will show changes needed to bring it back in sync.
If you want, I can also give:
- a Terraform-specific drift detection guide
- a CI/CD implementation example
- or a comparison of drift detection tools.