The Problem: Drift Detection in Infrastructure-as-Code
In production environments, infrastructure-as-code (IaC) tools like Terraform are widely used to manage and provision infrastructure. However, a common issue that arises is drift between the declared state in the IaC configuration and the actual state of the infrastructure. This drift can occur due to manual changes made in the console, hotfixes applied directly to resources, or scaling values tuned by hand. If left undetected, drift can lead to configuration inconsistencies, security vulnerabilities, and ultimately, outages.
Technical Breakdown
To understand how drift occurs, let's consider a simple Terraform configuration for an AWS EC2 instance:
# File: main.tf






