← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

Infrastructure Drift

devops Intermediate
debt(d7/e5/b7/t5)
d7 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'only careful code review or runtime testing' (d7). The term's detection_hints list terraform, aws-config, ansible, checkov, and driftctl — these are specialist tools that must be deliberately configured and scheduled; drift is not caught by default linters or compilers. Critically, the common_mistakes note that not running terraform plan in CI means drift is discovered during apply, and not alerting on ArgoCD sync failures means drift happens silently. Without proactive setup of these tools, drift accumulates invisibly in production — slightly better than d9 only because the tooling exists and can be automated.

e5 Effort Remediation debt — work required to fix once spotted

Closest to 'touches multiple files / significant refactor in one component' (e5). The quick_fix suggests running terraform plan or AWS Config rules on a schedule, but that only detects drift — remediating it requires auditing which manual changes were made, deciding whether to encode them in IaC or revert them, updating Terraform state, playbooks, or other IaC files across potentially multiple modules or stacks, and re-validating environments. A single console change (per the misconception) might be e3, but the common_mistakes describe patterns (shared state corruption, undocumented incident fixes) that compound into multi-file reconciliation work.

b7 Burden Structural debt — long-term weight of choosing wrong

Closest to 'strong gravitational pull' (b7). Infrastructure drift applies to web and cli contexts with IaC/GitOps tags, meaning it affects the entire infrastructure lifecycle. Every deployment, incident response, and environment promotion is shaped by whether drift exists. The common_mistakes show it corrupts shared terraform state, breaks CI/CD pipelines, and creates staging-vs-prod mysteries — a persistent, cross-cutting tax. It doesn't quite reach b9 (it doesn't redefine the system architecture) but it heavily shapes how every change must be made.

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'notable trap (a documented gotcha most devs eventually learn)' (t5). The misconception field explicitly states the trap: developers believe drift is only a problem for large systems, but a single manual console change on a small setup breaks the next terraform apply. This is a well-documented gotcha that many practitioners learn the hard way after an incident. It doesn't rise to t7/t9 because it doesn't contradict a concept from a different ecosystem — it's a domain-specific misunderstanding about scale and severity.

About DEBT scoring →

Also Known As

configuration drift terraform drift state drift

TL;DR

When the actual state of infrastructure diverges from its declared desired state — caused by manual changes, failed deployments, or out-of-band modifications that bypass IaC.

Explanation

Drift occurs when someone makes a change directly in the AWS console, runs a manual kubectl command, or modifies a server config by hand — bypassing the IaC codebase. The declared state (Terraform, CloudFormation) is now different from the actual state. terraform plan detects drift by comparing state file against real infrastructure. GitOps tools (ArgoCD) continuously reconcile and can auto-correct drift. Prevention: strict access controls (only CI/CD can deploy), immutable infrastructure (replace don't modify), and regular drift detection runs.

Common Misconception

Drift is only a problem for large systems — a single manual console change on a small AWS setup causes drift that breaks the next terraform apply or creates undocumented dependencies.

Why It Matters

Undetected drift causes 'it works in staging but breaks in prod' mysteries — the environments appear identical in code but differ in actual configuration.

Common Mistakes

  • Manual console changes during incidents without updating IaC — the fix works but drift is never documented.
  • Not running terraform plan in CI before apply — drift is discovered during apply, causing unexpected changes.
  • Shared terraform state without locking — concurrent applies corrupt state.
  • Not alerting on ArgoCD sync failures — drift happens silently without monitoring.

Code Examples

✗ Vulnerable
# Manual change during incident — creates drift:
# 3am incident: DB connections exhausted
# Engineer manually increases RDS max_connections in AWS console
# Incident resolved. Change never added to Terraform.
# Next terraform apply: reverts max_connections to old value
# Incident recurs. No one knows why — drift was the cause.
✓ Fixed
# Detect drift regularly:
# In CI (nightly):
terraform plan -detailed-exitcode
# Exit code 2 = changes detected (drift)
# Alert on-call if drift found

# Prevent manual changes:
# IAM policy: deny console changes to production
# Only CI/CD role can apply Terraform
# ArgoCD auto-sync corrects K8s drift immediately

Added 15 Mar 2026
Edited 22 Mar 2026
Views 35
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
4 pings F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 2 pings F 0 pings S 0 pings S 0 pings M 0 pings T 1 ping W 0 pings T 4 pings F 0 pings S 0 pings S 0 pings M 0 pings T 1 ping W 0 pings T 3 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 2 pings F 0 pings S
No pings yet today
Amazonbot 1
Amazonbot 18 Perplexity 3 Unknown AI 3 Google 2 Ahrefs 2 SEMrush 2 Majestic 1
crawler 30 pre-tracking 1
DEV INTEL Tools & Severity
🟠 High ⚙ Fix effort: Medium
⚡ Quick Fix
Run terraform plan or AWS Config rules on a schedule to detect drift — any difference between your IaC definition and actual infrastructure is drift that will cause the next deployment to fail
📦 Applies To
any web cli
🔗 Prerequisites
🔍 Detection Hints
Infrastructure changed manually in console without updating Terraform; server configuration drifted from Ansible playbook; undocumented production config change
Auto-detectable: ✓ Yes terraform aws-config ansible checkov driftctl
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: Medium ✗ Manual fix Fix: High Context: File
CWE-1188

✓ schema.org compliant