<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sudarshan Thakur</title>
    <description>The latest articles on DEV Community by Sudarshan Thakur (@sudarshan_thakur_1e141b99).</description>
    <link>https://dev.to/sudarshan_thakur_1e141b99</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3891239%2F5a0d3691-a976-495d-a4ad-2e622643e944.JPG</url>
      <title>DEV Community: Sudarshan Thakur</title>
      <link>https://dev.to/sudarshan_thakur_1e141b99</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sudarshan_thakur_1e141b99"/>
    <language>en</language>
    <item>
      <title>I Built tfdrift Free Terraform Drift Detection With Severity Alerts</title>
      <dc:creator>Sudarshan Thakur</dc:creator>
      <pubDate>Tue, 21 Apr 2026 19:31:10 +0000</pubDate>
      <link>https://dev.to/sudarshan_thakur_1e141b99/i-built-tfdrift-free-terraform-drift-detection-with-severity-alerts-2n96</link>
      <guid>https://dev.to/sudarshan_thakur_1e141b99/i-built-tfdrift-free-terraform-drift-detection-with-severity-alerts-2n96</guid>
      <description>&lt;h1&gt;
  
  
  I Built a Free Terraform Drift Detector — Here's Why
&lt;/h1&gt;

&lt;p&gt;If you manage Terraform infrastructure, you've probably experienced this: someone tweaks a security group in the AWS console "just for testing," forgets about it, and three months later your &lt;code&gt;terraform apply&lt;/code&gt; blows up — or worse, that change silently creates a security hole that nobody catches.&lt;/p&gt;

&lt;p&gt;This is infrastructure drift. And there's no good free tool to detect it properly.&lt;/p&gt;

&lt;p&gt;So I built &lt;a href="https://github.com/sudarshan8417/tfdrift" rel="noopener noreferrer"&gt;&lt;strong&gt;tfdrift&lt;/strong&gt;&lt;/a&gt; — a free, open-source CLI that detects Terraform drift, classifies it by severity, and alerts your team.&lt;/p&gt;




&lt;h2&gt;
  
  
  The problem with "just run terraform plan"
&lt;/h2&gt;

&lt;p&gt;Yes, &lt;code&gt;terraform plan&lt;/code&gt; detects drift. But in practice, it falls short for teams managing real infrastructure:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No severity awareness.&lt;/strong&gt; Someone changed a tag? Same alert as someone opening port 22 to the world. &lt;code&gt;terraform plan&lt;/code&gt; treats all changes equally — but they're not. An IAM policy change is a security incident. A tag change is noise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No multi-workspace scanning.&lt;/strong&gt; If you have 20 Terraform workspaces across environments, you need to &lt;code&gt;cd&lt;/code&gt; into each one and run &lt;code&gt;plan&lt;/code&gt; manually. Nobody does this consistently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No notifications.&lt;/strong&gt; You only discover drift when you happen to run &lt;code&gt;plan&lt;/code&gt;. By then, the damage may already be done.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No ignore rules.&lt;/strong&gt; Auto-scaling groups constantly change &lt;code&gt;desired_capacity&lt;/code&gt;. ECS services change &lt;code&gt;desired_count&lt;/code&gt;. These are expected — but &lt;code&gt;plan&lt;/code&gt; flags them every time, creating alert fatigue.&lt;/p&gt;




&lt;h2&gt;
  
  
  What tfdrift does
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;tfdrift
tfdrift scan &lt;span class="nt"&gt;--path&lt;/span&gt; ./infrastructure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It recursively discovers all Terraform workspaces, runs &lt;code&gt;terraform plan -json&lt;/code&gt; on each, parses the output, and gives you a structured report with severity classification:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CRITICAL&lt;/strong&gt; — Security group ingress/egress changes, IAM policy modifications, S3 public access changes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HIGH&lt;/strong&gt; — Instance type changes, RDS public accessibility, encryption config changes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MEDIUM&lt;/strong&gt; — Most other attribute changes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LOW&lt;/strong&gt; — Tags, descriptions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's what the output looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;⚠️  Drift detected: 7 resource(s) across 2/4 workspace(s)

🔴 critical: 2  🟠 high: 2  🟡 medium: 2  🔵 low: 1

📂 infrastructure/production (5 drifted, 3.2s)
┌──────────┬───────────────────────────────────┬────────┬─────────────────────┐
│ Severity │ Resource                          │ Action │ Changed attributes  │
├──────────┼───────────────────────────────────┼────────┼─────────────────────┤
│ CRITICAL │ aws_security_group.api_sg         │ update │ ingress             │
│ CRITICAL │ aws_iam_role_policy.lambda_exec   │ update │ policy              │
│ HIGH     │ aws_instance.web_server           │ update │ instance_type, ami  │
│ HIGH     │ aws_rds_instance.primary          │ update │ publicly_accessible │
│ LOW      │ aws_s3_bucket.assets              │ update │ tags                │
└──────────┴───────────────────────────────────┴────────┴─────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you immediately know what matters.&lt;/p&gt;




&lt;h2&gt;
  
  
  I tested it against real AWS infrastructure
&lt;/h2&gt;

&lt;p&gt;To validate the tool beyond unit tests, I set up a sample AWS environment with EC2 instances managed by Terraform. I ran tfdrift against it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tfdrift scan &lt;span class="nt"&gt;--path&lt;/span&gt; ./dev-terraform/development/ec2 &lt;span class="nt"&gt;--verbose&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Within 4 seconds, it detected a drifted EC2 instance — an &lt;code&gt;aws_instance&lt;/code&gt; resource that had been modified outside of Terraform. The tool correctly classified it as &lt;strong&gt;HIGH&lt;/strong&gt; severity because &lt;code&gt;instance_type&lt;/code&gt; was among the changed attributes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;⚠️  Drift detected: 1 resource(s) across 1/4 workspace(s)

🟠 high: 1

📂 development/ec2/dev-machines (1 drifted, 4.2s)
┌──────────┬──────────────────────┬────────┬────────────────────────────────────┐
│ Severity │ Resource             │ Action │ Changed attributes                 │
├──────────┼──────────────────────┼────────┼────────────────────────────────────┤
│ HIGH     │ aws_instance.this[0] │ create │ instance_type, tags, monitoring,  │
│          │                      │        │ metadata_options, volume_tags      │
└──────────┴──────────────────────┴────────┴────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That drift had been sitting there undetected. A simple &lt;code&gt;terraform plan&lt;/code&gt; would have found it too — but nobody was running &lt;code&gt;plan&lt;/code&gt; against that workspace regularly. With tfdrift's watch mode, this could have been caught automatically and sent to Slack within minutes.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key features
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Watch mode&lt;/strong&gt; — continuous monitoring with Slack alerts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tfdrift watch &lt;span class="nt"&gt;--interval&lt;/span&gt; 30m &lt;span class="nt"&gt;--slack-webhook&lt;/span&gt; https://hooks.slack.com/services/XXX
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Auto-remediation&lt;/strong&gt; — with safety guards that block destructive changes on critical resources:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tfdrift scan &lt;span class="nt"&gt;--auto-fix&lt;/span&gt; &lt;span class="nt"&gt;--confirm&lt;/span&gt; &lt;span class="nt"&gt;--env&lt;/span&gt; dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Ignore rules&lt;/strong&gt; — a &lt;code&gt;.tfdriftignore&lt;/code&gt; file for expected drift:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws_autoscaling_group.*.desired_capacity
aws_ecs_service.*.desired_count
*.tags.LastModified
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CI/CD integration&lt;/strong&gt; — exit codes designed for pipelines (0 = clean, 1 = drift, 2 = error, 3 = remediated), plus a ready-made GitHub Actions workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JSON and Markdown output&lt;/strong&gt; — for programmatic use or generating reports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tfdrift scan &lt;span class="nt"&gt;--format&lt;/span&gt; json &lt;span class="nt"&gt;--output&lt;/span&gt; drift-report.json
tfdrift scan &lt;span class="nt"&gt;--format&lt;/span&gt; markdown &lt;span class="nt"&gt;--output&lt;/span&gt; drift-report.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  How it compares
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;tfdrift&lt;/th&gt;
&lt;th&gt;terraform plan&lt;/th&gt;
&lt;th&gt;Terraform Enterprise&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Actively maintained&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Severity classification&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multi-workspace scan&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auto-remediation&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Watch mode + alerts&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ignore rules&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;td&gt;$15K+/yr&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  The architecture
&lt;/h2&gt;

&lt;p&gt;tfdrift is written in Python and built with a modular architecture:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tfdrift/
├── detectors/       # Drift detection engine (terraform plan parser)
├── reporters/       # Output formatters (JSON, Markdown, table, Slack)
├── remediators/     # Auto-fix logic with safety guards
├── severity.py      # 30+ built-in AWS severity rules
├── config.py        # .tfdrift.yml and .tfdriftignore parser
└── cli.py           # CLI (Click)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The severity engine uses pattern matching to classify drift. For example, any change to &lt;code&gt;aws_security_group.*.ingress&lt;/code&gt; is automatically classified as CRITICAL, while &lt;code&gt;*.tags&lt;/code&gt; changes are classified as LOW. You can extend these rules in your &lt;code&gt;.tfdrift.yml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;critical&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;aws_security_group.*.ingress&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;aws_iam_policy.*.policy&lt;/span&gt;
  &lt;span class="na"&gt;high&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;aws_instance.*.instance_type&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;aws_rds_instance.*.publicly_accessible&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Why I built this
&lt;/h2&gt;

&lt;p&gt;I'm a DevOps engineer working with AWS, Terraform, and Kubernetes daily. Infrastructure drift was a recurring problem — security-critical changes mixed in with harmless noise, and no good free tool to sort through it.&lt;/p&gt;

&lt;p&gt;The existing options were either expensive (Terraform Enterprise at $15K+/year) or too basic (raw &lt;code&gt;terraform plan&lt;/code&gt; in a cron job).&lt;/p&gt;

&lt;p&gt;I wanted something that could:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tell me &lt;strong&gt;what&lt;/strong&gt; drifted and &lt;strong&gt;how bad&lt;/strong&gt; it is&lt;/li&gt;
&lt;li&gt;Scan all my workspaces in one command&lt;/li&gt;
&lt;li&gt;Send me a Slack alert at 2 AM when someone modifies a security group&lt;/li&gt;
&lt;li&gt;Let me ignore the noise (auto-scaling changes, tag updates)&lt;/li&gt;
&lt;li&gt;Run in CI/CD and fail the pipeline if critical drift is found&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I built it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;tfdrift

&lt;span class="c"&gt;# Scan your infrastructure&lt;/span&gt;
tfdrift scan &lt;span class="nt"&gt;--path&lt;/span&gt; ./your-terraform-dir

&lt;span class="c"&gt;# Set up continuous monitoring&lt;/span&gt;
tfdrift watch &lt;span class="nt"&gt;--interval&lt;/span&gt; 1h &lt;span class="nt"&gt;--slack-webhook&lt;/span&gt; &lt;span class="nv"&gt;$SLACK_WEBHOOK&lt;/span&gt;

&lt;span class="c"&gt;# Generate a config file&lt;/span&gt;
tfdrift init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code is fully open source: &lt;strong&gt;&lt;a href="https://github.com/sudarshan8417/tfdrift" rel="noopener noreferrer"&gt;github.com/sudarshan8417/tfdrift&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I'd love feedback, bug reports, and contributions. If you've dealt with Terraform drift at your organization, I'd especially love to hear what features you'd want next — Azure/GCP support, a web dashboard, PagerDuty integration?&lt;/p&gt;

&lt;p&gt;Drop a comment or &lt;a href="https://github.com/sudarshan8417/tfdrift/issues" rel="noopener noreferrer"&gt;open an issue on GitHub&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;If you found this useful, consider giving the repo a ⭐ on GitHub — it helps other engineers find the tool.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>security</category>
      <category>automation</category>
      <category>cloud</category>
    </item>
  </channel>
</rss>
