Forum Discussion
VishwaSanthosh
Nov 30, 2026Copper Contributor
Infrastructure as Code Is Not Enough: How Do We Handle Configuration Drift in Cloud Environments?
Hi everyone,
Infrastructure as Code (IaC) has significantly changed how organizations provision and manage cloud infrastructure.
Instead of manually creating resources through a cloud portal, administrators and DevOps engineers can define infrastructure configurations in code and deploy them consistently across different environments.
With technologies such as Terraform, Azure Bicep, ARM templates, and Azure DevOps Pipelines, infrastructure provisioning has become more repeatable, scalable, and manageable.
However, I believe there is another challenge that deserves more attention:
What happens when the actual cloud infrastructure starts differing from the configuration defined in our code?
This is commonly known as configuration drift.
Understanding configuration drift
Configuration drift occurs when the actual state of an infrastructure resource differs from its intended or declared configuration.
Consider a simple example.
An organization provisions an Azure Virtual Machine using Terraform.
The original configuration specifies:
- A particular VM size.
- A specific network configuration.
- Defined inbound and outbound security rules.
- A managed disk configuration.
- A set of monitoring and diagnostic settings.
Everything is deployed successfully.
A few weeks later, an administrator manually modifies the VM configuration through the Azure Portal to troubleshoot a production issue.
Another administrator changes an NSG rule to temporarily allow additional connectivity.
A third change is made to the VM size to accommodate increased workload requirements.
Although these changes might solve immediate operational problems, the Terraform configuration remains unchanged.
Now, there are two different versions of the infrastructure:
- The infrastructure currently running in Azure.
- The infrastructure defined in the Terraform configuration.
Over time, these differences can become difficult to track and manage.
Why configuration drift is a problem
I see several challenges associated with unmanaged configuration drift.
Infrastructure inconsistency
Different environments might gradually develop different configurations, even when they were initially deployed using the same template.
For example, development, testing, and production environments may no longer follow the same baseline.
Unexpected deployment changes
When an IaC deployment is executed again, the deployment tool might identify differences between the declared configuration and the actual infrastructure.
Depending on the configuration and the changes involved, this could result in unexpected modifications or resource replacement.
Security and compliance risks
Manual changes to NSGs, firewall rules, identity permissions, and resource configurations can introduce security gaps.
These changes may also cause resources to fall outside the organization's approved configuration baseline.
Troubleshooting complexity
When an infrastructure issue occurs, administrators might investigate the original deployment configuration without realizing that someone manually modified the resource afterward.
This increases troubleshooting time and makes operational documentation less reliable.
How can we manage configuration drift?
There are several approaches that organizations can consider.
Establish IaC as the primary source of truth
Infrastructure changes should ideally be introduced through version-controlled configuration files rather than directly through the portal.
Where emergency changes are necessary, they should subsequently be documented and incorporated into the IaC repository.
Use Terraform plan and state management
Terraform provides planning capabilities that help identify differences between the desired configuration and the infrastructure state.
Running regular Terraform plans can help teams identify unexpected changes before applying new infrastructure modifications.
It is important to remember that Terraform state is not an independent security or compliance audit log. Changes made outside Terraform must still be detected and reviewed appropriately.
Implement Azure Policy
Azure Policy can help enforce organizational standards across Azure resources.
For example, organizations can define policies requiring:
- Approved virtual machine SKUs.
- Specific resource tags.
- Diagnostic settings.
- Approved regions.
- Required security configurations.
Depending on the policy effect, non-compliant configurations can be audited, denied, or remediated.
Integrate validation into CI/CD pipelines
Infrastructure deployment pipelines can include additional validation stages.
For example:
- Terraform formatting and validation.
- Infrastructure plan generation.
- Policy compliance checks.
- Approval workflows.
- Controlled deployment.
This creates a more structured approach to infrastructure changes.
Maintain proper change management
Not every infrastructure change can be fully automated.
Production environments sometimes require emergency changes, troubleshooting activities, or approved manual interventions.
The important thing is to ensure that these changes are recorded, reviewed, and eventually reflected in the intended infrastructure configuration.
An interesting scenario to consider
Imagine an organization managing 200 Azure Virtual Machines across multiple subscriptions.
All 200 VMs were initially deployed through a standardized Terraform configuration.
Over six months:
- 20 VMs received manual configuration changes.
- 10 VMs had their network security rules modified.
- 15 VMs received additional disks.
- Several resources had their monitoring configurations changed.
The infrastructure may continue operating normally, but the original IaC configuration no longer represents the complete environment.
How would we identify all these differences?
Would periodic Terraform plan execution be sufficient?
Or should organizations implement a broader configuration compliance and drift detection strategy using Azure Policy, Azure Resource Graph, automation, and deployment pipeline validation?
I think this is an important consideration, especially as cloud environments become larger and more distributed.
Questions for the community
I would be interested in understanding how other organizations manage this challenge.
- Do you enforce a strict IaC-only approach for production infrastructure changes?
- How frequently do you run Terraform plans or equivalent configuration validation?
- Do you use Azure Policy to identify and prevent configuration drift?
- How do you handle emergency changes made directly through the Azure Portal?
- Do you believe configuration drift should be treated primarily as a DevOps responsibility or as part of overall cloud governance?
Looking forward to hearing your experiences, recommendations, and approaches.
Thanks!
No RepliesBe the first to reply