What is Infrastructure as Code (IaC) drift, and how do DevSecOps pipelines detect and remediate it?
Quick Revision Summary
Guide to understanding Infrastructure as Code (IaC) configuration drift, security risks of manual console changes (ClickOps), and automated detection using Terraform plan, driftctl, and GitOps.
Interactive Practice Mode
Formulate your thoughts or take notes before revealing the model solution.
Saved automatically
Model Answer & Deep-Dive Explanation
Infrastructure as Code (IaC) Drift occurs when the actual state of deployed cloud resources deviates from the declared configuration stored in version control (e.g., Terraform or OpenTofu manifests), typically caused by emergency manual edits in the cloud console ("ClickOps") or external automated scripts.
Why Drift is a Critical Security Hazard:
- Security Regression: An engineer opens port 22 to
0.0.0.0/0on a production firewall for temporary troubleshooting and forgets to close it. The Terraform code shows port 22 closed, creating a false sense of compliance. - Unpredictable Deployments: The next automated pipeline run may unexpectedly overwrite or destroy unmanaged resources.
Automated Detection & Remediation Architecture:
- Scheduled Non-Destructive Scans: Configure scheduled CI/CD jobs (e.g., running every 6 hours) executing
terraform plan -detailed-exitcode. Exit code2alerts the team that drift exists without modifying resources. - GitOps Policy Enforcement: Use tools like driftctl or ArgoCD to continuously reconcile declared Git state with live cloud state, raising Slack/PagerDuty alerts when unauthorized changes appear.
- Console Lockdown: Revoke write permissions in the AWS/Azure console, enforcing that ALL infrastructure modifications must be committed to Git and approved via pull request.
Interviewer Evaluation Points & Scoring Rubric
- 1 Definition of IaC drift (code state vs real-world cloud state)
- 2 Risks introduced by unversioned manual changes (security group holes)
- 3 Automated drift detection using scheduled pipelines and driftctl
- 4 Remediation strategies: reconciliation vs importing
Related Questions in Cloud & DevOps Engineering
Explain the difference between CSPM, CIEM, and CWPP in modern cloud security.
Intermediate level • 305 views
How do you secure containerized microservices and Kubernetes clusters against privilege escalation and lateral movement?
Advanced level • 298 views
How would you perform a canary release and decide whether to continue or roll back?
Medium level • 99 views
How is a container different from a virtual machine?
Easy level • 89 views
How do IaaS, PaaS, and SaaS divide operational responsibility?
Easy level • 88 views