DEV Community

Sudarshan Thakur
Sudarshan Thakur

Posted on

Drift Detection Was Never the Hard Part — Here's What Production Teams Actually Need Next

When I started building tfdrift, the problem seemed simple: terraform plan tells you what changed, but not how much you should care. Severity classification solved that — and it's been the core of tfdrift since v0.1.

But shipping severity classification to real teams surfaced a different set of questions. Not "is this drift dangerous," but:

  • Who suppressed this alert, and why?
  • Is this week's drift normal, or is something actually wrong?
  • Will fixing this blow our cloud budget?
  • Can we act on this automatically, safely?
  • How do we stop paging the same unresolved drift every hour?

None of that is about detecting drift better. It's about running drift detection like a piece of production infrastructure, not a script someone runs on Fridays. That's what this release is about.

Who suppressed this, and when?

Every drift tool eventually accumulates suppressions — expected drift, false positives, "we know about this, ignore it." The problem is that suppressions are invisible. Six months later, nobody remembers why a Critical-severity S3 policy change was silenced, or who approved silencing it.

tfdrift now keeps an immutable audit log of every suppress and clear action in SQLite:

tfdrift audit-log --since 30d --action suppress --format table
Enter fullscreen mode Exit fullscreen mode

This sounds like a small feature. In practice, it's the difference between "we have a drift tool" and "we have a drift tool a security review will actually approve." Compliance-minded teams don't just want alerts — they want a paper trail.

Is this normal, or is something wrong?

A single drift event rarely tells you much. A spike does. tfdrift now computes a rolling 7-day average drift count from its own history and can flag when current drift exceeds that baseline:

tfdrift scan --anomaly-threshold 50
Enter fullscreen mode Exit fullscreen mode

If your infrastructure normally sees 8-10 drift events a day and today it's 40, that's not noise — that's a signal something changed upstream (a misconfigured CI job, a compromised credential, a bad migration). Severity classification tells you which individual changes matter; anomaly detection tells you when the pattern itself is the problem.

Will fixing this blow the budget?

Every DevOps team has had the conversation where "just apply the fix" turns into a surprise five-figure AWS bill. tfdrift now estimates the monthly cost delta of drifted resources and can gate on it:

tfdrift scan --budget-threshold 500
Enter fullscreen mode Exit fullscreen mode

Cost impact now surfaces in the JSON summary, the HTML report's stat card, and a new cost_delta_monthly column in CSV exports — so cost isn't a separate spreadsheet exercise, it's part of the same triage view as severity.

Closing the loop, safely

Detection is only useful if someone (or something) acts on it. tfdrift's remediation flow now supports pre- and post-apply hooks:

remediation:
  pre_apply_hook: ./scripts/notify-oncall.sh
  post_apply_hook: ./scripts/verify-rollback.sh
Enter fullscreen mode Exit fullscreen mode

A failed pre-hook aborts remediation before anything touches infrastructure. A failed post-hook logs a warning rather than blocking — the assumption being that verification failures are worth knowing about, but shouldn't leave infrastructure half-remediated.

Alert fatigue, round two

My IEEE IC2E paper on severity taxonomies was about volume — filtering out noise so security-relevant drift doesn't get lost. But even severity-filtered alerts get old fast if the same unresolved drift pages you every hour. Digest mode fixes that:

notifications:
  digest_mode: true
  digest_hours: 12
Enter fullscreen mode Exit fullscreen mode

With digest mode on, a resource that's still drifted from last time doesn't re-alert — you only hear about it once per window, or when something actually changes. Alert fatigue isn't just about volume; it's about repetition.

Also in this release

  • Owner attribution — drift reports now surface owner, team, costcenter, and contact tags pulled straight from the Terraform plan, so "who owns this resource" isn't a Slack scavenger hunt.
  • Redesigned HTML reports — before/after attribute diffs, rendered inline (red for old values, green for new), instead of a flat list of changed keys.

Why this matters more than it looks like

None of these features are complicated in isolation. What they add up to is a shift in what tfdrift is: not a script that flags drift, but infrastructure a team can actually run, audit, and trust — with a paper trail, a cost lens, and a way to stay quiet when it should.

That's the harder problem, and it's the one I think matters more long-term than detection accuracy alone.


tfdrift is open-source and available at github.com/sudarshan8417/tfdrift. Install with pip install tfdrift. If you're running Terraform at scale and any of this resonates, I'd love to hear how you're handling it today.

Top comments (1)

Collapse
 
alexshev profile image
Alex Shev

This is the kind of engineering detail that usually matters more in production than the headline feature. Small boundaries compound when a workflow runs every day.