Infrastructure as Code: Principles, Patterns, and Pitfalls in Cloud-Native DevOps Environments
Infrastructure as Code (IaC) represents a paradigm shift in how cloud infrastructure is provisioned, managed, and evolved, yet its practical adoption is accompanied by a set of under-documented failure patterns. This paper conducts a systematic literature review of 94 peer-reviewed publications combined with a practitioner survey of 340 DevOps engineers across North America and Europe. We categorize IaC tools into three architectural families — declarative, imperative, and hybrid — and evaluate them against six quality dimensions: idempotency, modularity, testability, auditability, portability, and drift detection. Our survey reveals that 67% of teams encounter configuration drift within six months of initial deployment, and that fewer than 30% implement automated compliance checks on their IaC manifests. We introduce the concept of "infrastructure entropy" to describe the gradual degradation of alignment between declared and actual infrastructure state, and propose a set of 14 engineering practices — collectively termed the IaC Hygiene Framework — to mitigate it. Case evidence from three organizations using Terraform, Ansible, and Pulumi respectively is used to validate the framework. This research provides both theoretical grounding and practical tooling guidance for organizations pursuing robust cloud infrastructure automation.