Terraform Drift Calculator
Calculate the percentage of resources that have drifted from their Terraform state.
About Terraform Drift Calculator
Drift occurs when real infrastructure diverges from what's recorded in Terraform state — typically from manual console changes or out-of-band automation. Formula: drift% = resources_with_diff / total_resources × 100. The risk score weights raw drift percentage alongside how many drifted resources are critical (security groups, IAM, production data stores), since a small number of critical drifted resources can matter more than a larger number of low-stakes ones.
Formulas
Drift percentage
drift_percent = (resources_with_diff / total_resources) × 100
- resources_with_diff
- Resources where real state differs from Terraform state
- total_resources
- Total managed resources
Risk score
risk_score = clamp(drift_percent × 1.5 + critical_drifted × 15, 0, 100)
- drift_percent
- Overall drift percentage
- critical_drifted
- Number of critical resources that have drifted
Worked example
With the default values below, Terraform Drift Calculator returns Infrastructure Drift of 6.00%. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Resources with Driftaccepts 0–1,000,000 resources
- 9 resources
- Total Managed Resourcesaccepts 1–10,000,000 resources
- 150 resources
- Critical Resources Driftedaccepts 0–1,000,000 resources
- 2 resources
Results
- Infrastructure Drift
- 6.00%
- Drift Risk Level
- Moderate
- Risk Score
- 39.0 /100
- Critical Share of Drift
- 22.2%
Step by step
- 1Drift %: drifted / total= 6.00%
- 2Risk score: drift×1.5 + critical×15= 39.0
Assumptions and limits
- The result is derived only from the 3 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 2 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
How do I detect drift in Terraform?
Run `terraform plan -refresh-only` (or `terraform plan` in older versions) to compare real infrastructure against state without making changes — any diffs shown are drift.
What commonly causes drift?
Manual changes made directly in a cloud console or CLI, auto-scaling and managed services that change attributes outside Terraform's control, and other automation (e.g. a security team's compliance tooling) modifying resources Terraform also manages.
How do I fix drift?
Either update your Terraform configuration to match the real state and apply (adopting the manual change), or run `terraform apply` to revert the resource back to what's declared in code — the right choice depends on which is the source of truth.
How often should I check for drift?
Many teams run scheduled drift detection (daily or on a CI cron) for production infrastructure, since undetected drift compounds and makes the next real `apply` riskier and harder to predict.
Related Calculators
- Terraform Plan Complexity Calculator
- Terraform Infrastructure Score Calculator
- Terraform Resource Count Calculator
- Terraform Apply Time Calculator
- Terraform Backend Storage Calculator
- Terraform Cloud Cost Calculator
- Terraform Graph Complexity Calculator
- Terraform Lock Timeout Calculator
- Terraform Module Dependency Calculator
- Terraform Refresh Duration Calculator
You might also need
- Terraform Resource Count CalculatorCommonly used together
- Terraform Infrastructure Score CalculatorCommonly used together
- Terraform Plan Complexity CalculatorCommonly used together
- Terraform Apply Time CalculatorAlso in Terraform
- Terraform Workspace CalculatorAlso in Terraform
- Terraform Graph Complexity CalculatorAlso in Terraform
