Infrastructure is increasingly described as code — Terraform, Ansible, Kubernetes manifests — with the expectation that the description matches reality. But servers live a life of their own: an engineer opens a console and raises a memory limit, a database administrator applies a patch, an automation script changes a firewall rule. Each change is harmless on its own; together they add up to configuration drift.
Where drift comes from
| Cause | Example |
|---|---|
| Manual changes | an engineer changes a setting in the cloud web console without touching the code |
| Emergency fixes | during a night-time incident the configuration is edited directly, and porting the change back to the repository is later forgotten |
| Scripts and agents | a local script, a cron job or an auto-update utility quietly changes files and packages |
| Urgent security updates | a patch is applied to some servers — some nodes get the new version while others stay on the old one |
| Copied environments | staging and production were deployed at different times from different versions of the description |
Why it’s dangerous
The main risk is that drift goes unnoticed. The on-call engineer believes one version of the service is deployed, while three of the twelve nodes run an older one. A new engineer runs the command from the documentation and it behaves unexpectedly, because the actual server has long since diverged from it. Drift also complicates disaster recovery: rebuilding an environment from code yields a configuration that did not exist at the time of the failure.
$ terraform plan -refresh-only Note: Objects have changed outside of Terraform # aws_instance.example has been changed~ instance_type = "t2.micro" -> "t3.large" Terraform has detected a change outside the code; a plain apply would revert the machine to t2.micro.How drift is found and resolved
- Detection: comparing the live infrastructure with the description — for Terraform this is
terraform plan -refresh-only. - Accepting changes: if the edit is needed, it is added to the code; if not, the code is applied again and the edit is rolled back.
- Prevention: manual changes to production are forbidden, and all changes go through the repository and the CI/CD pipeline.
Immutable infrastructure and GitOps guard against drift: an agent continuously compares the actual state with the desired state in Git and brings deviations back in line with the description. In fast-moving systems drift never disappears entirely — it is made visible and kept under control.
Sources
the term is written from these pages- HashiCorp — Manage resource drift (Terraform tutorial)developer.hashicorp.com/terraform/tutorials/state/resource-drift(opens in a new tab)
- Microsoft Learn — Architecture strategies for using infrastructure as codelearn.microsoft.com/en-us/azure/well-architected/operational-excellence/infrastructure-as-code-design(opens in a new tab)
- OpenGitOps Principles v1.0.0opengitops.dev(opens in a new tab)
Verified 9 Nov