Use this when systems drift away from their declared configuration.
Drift Management
Drift management compares the actual state of systems with the desired state in code, reports differences and fixes them automatically or manually, keeping configuration consistent over time.
1. Drift management: detect, report, remediate, prevent.
2. Decide what auto-remediates.
3. Find who/what causes drift.
4. Restrict manual changes.
5. Track trends.
desired vs actual → drift → report → remediate → prevent
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Target-state verification ladder Verify boundary
Drift Management uses a strict target-state ladder for desired/observed state comparison and reconciliation: request accepted → job/task succeeded → target object changed → effective runtime state confirmed → original workload verified.
Step 2 Verification path Verify boundary
Verify drift management with controlled, reversible experiments. Establish a converged baseline and run the detector until it reports no unexpected change. Make one bounded out-of-band change to an owned property and confirm the detector reports the precise resource/property without mutating it. Classify the difference, then exercise the chosen path: reconcile it back, adopt it into declared intent/state, or create a time-bounded exception. Re-run detection and independently query the target to show the final state matches the chosen policy. Also test a change to an unmanaged/computed property to ensure noise is not reported as actionable drift. Record configuration revision, state/workspace ID, provider version, target identity, diff and decision so future comparisons are meaningful.
Step 3 Where it fails Narrow the fault
The main boundaries are declared intent, state store/controller knowledge, provider/API read semantics and actual target state. A difference can originate from manual change, another controller, stale/failed refresh, provider normalization, eventual consistency or true policy violation. Do not apply automatically until the owner and difference class are known. A refresh-only operation updates state representation and is not the same as reconciling infrastructure; conversely, a normal plan may propose destructive reconciliation when the real issue is outdated configuration. Preserve state backups and original diffs before adoption. If the detector itself cannot read a resource, classify that as visibility failure rather than “no drift.” Re-run the same detector and service read-back after corrective action.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Subtopics
Go one level deeper into this subject.
Configuration drift is the gradual divergence of systems from their intended configuration through manual fixes, ad hoc changes and partial runs, leading to inconsistent and fragile environments.
Subtopic Desired StateDesired state in drift management is the authoritative definition of how systems should be, kept in Git or a source of truth, against which actual state is measured.
Subtopic Actual StateActual state is the real, current configuration of a system as observed by reading it, which drift management compares with the desired state to find differences.
Subtopic Drift DetectionDrift detection in drift management runs scheduled comparisons — terraform plan, Ansible check mode, GitOps diff, config backups compared in Git — and flags any differences.
Subtopic Drift ReportingDrift reporting summarizes which systems drifted, what changed, when and how often, so teams can fix root causes such as people bypassing automation.
Subtopic Auto-remediationAuto-remediation in drift management automatically applies the desired state when drift is found.
Subtopic Manual RemediationManual remediation is when an engineer reviews detected drift and decides whether to revert it or update the desired state, appropriate when an automatic fix might cause harm.
Subtopic Compliance DriftCompliance drift is when systems that once passed compliance checks fall out of compliance through changes or new requirements, tracked as a trend so it is fixed before an audit.
- Drift comes from manual changes, failed runs or other tools.
- Detect first, then decide: fix the system or update the code.
- Report drift trends to find root causes.
- Drift reports per system — visibility
- Remediation policy (auto vs manual) — decision
- Drift sources analysis — prevention
ReferenceWhy it matters1 section · depth on demand
In depth
Drift management detects, reports and resolves differences between intended and actual configuration over time. It keeps automated environments trustworthy, because automation assumes systems are in the state it last left them.
| Activity | Example |
|---|---|
| Detect | Scheduled dry runs, config diffs |
| Classify | Expected, emergency fix, unauthorised |
| Resolve | Revert, or update desired state |
| Prevent | Restrict manual access, enforce via pipeline |
Track drift volume per team and system; repeated drift points to processes that bypass automation.
ReferenceImportant terms & boundaries1 section · depth on demand
Mechanics
Drift Management compares at least three things: declared intent, automation/controller state, and actual remote system state. In tools such as Terraform, refresh updates the controller’s view of remote objects before planning, so a plan can expose both out-of-band changes and configuration changes. Not every difference is unwanted drift: an approved emergency change, an autoscaled attribute, provider-computed field or another controller’s owned property may be legitimate. Effective drift management therefore depends on ownership metadata and normalization rules as much as on diff detection. A system that automatically overwrites every difference can destroy authorized changes; a system that merely refreshes state can silently adopt unauthorized changes. The core technical decision is whether to reconcile actual state to desired intent, adopt actual state into intent/state, or record an explicit exception.
ReferenceConfiguration & state1 section · depth on demand
Lifecycle
Run drift detection on a defined cadence and from the same reviewed configuration, provider/module versions and credentials used for enforcement. Track ownership at resource/property level where multiple controllers or humans can legitimately change the same system. Define an exception lifecycle with owner, rationale, expiry and revalidation so ignores do not become permanent blind spots. When drift is found, preserve the original diff and associated change/audit records before remediation. For stateful IaC tools, protect state storage, locking and backups because state corruption can masquerade as drift. Provider upgrades and schema changes should trigger baseline review. Repeated drift on the same field is usually a design/ownership conflict that should be resolved at source, not an invitation to increase remediation frequency.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in > Drift Management. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://developer.hashicorp.com/terraform/tutorials/state/resource-drift · confidence 94%Quick lookup tables
→ Drift Management · operational reference
Context-specific ownership, verification, output and failure-boundary lookup for → Drift Management.
| Layer | Drift Management operational reference |
|---|---|
| Runtime/ownership | Terraform / declarative automation current · identify controller/worker/target ownership before mutation |
| Persistent intent | Versioned configuration/playbook/workflow with explicit dependencies and least-privilege identity |
| Verification | terraform plan -refresh-only -detailed-exitcode; terraform plan -detailed-exitcode |
| Expected interpretation | The workflow distinguishes actual remote state from recorded state and desired configuration, classifies authorized vs unauthorized divergence, and chooses adopt/reconcile/ignore deliberately. |
| Recovery boundary | Preserve correlation IDs + pre-state, then verify target/service independently after remediation |
Deep reference
Healthy vs suspicious evidence
Output interpretation
Drift output should separate “remote object changed,” “controller state changed,” and “desired configuration changed.” Preserve stable resource addresses/IDs and property-level before/after values, not only a generic changed count. Terraform refresh-only and normal plans communicate different intents, so label them explicitly in audit records. For scheduled detection, aggregate counts by owner/system while retaining links to the exact diff. Sensitive values should be redacted or hashed; their existence/change can still be reported. A clean detector run should also state coverage and skipped/unknown resources so absence of findings is not mistaken for complete coverage. After remediation, store the follow-up clean plan/diff together with an independent target query as closure evidence.