Infrastructure as Code (IaC): Declarative Provisioning, Drift Detection, and GitOps

Infrastructure as Code (IaC) is the foundational DevOps practice of managing and provisioning cloud compute, storage, networking, and security configurations through machine-readable definition files rather than manual physical hardware configuration or interactive web console clicks.

This guide details declarative versus imperative IaC models, automated drift detection, GitOps continuous delivery workflows (ArgoCD / Flux), and immutable infrastructure patterns.


1. Quick-Reference: IaC Tooling Landscape

+-----------------------------------------------------------------------------------------+
|                               IAC TOOLING COMPARISON                                    |
+-----------------------------------------------------------------------------------------+
| Tool / Framework       | Paradigm                          | Primary Strength           |
+------------------------+-----------------------------------+----------------------------+
| Terraform / OpenTofu   | Declarative HCL                   | Cloud resource provisioning|
| Pulumi / AWS CDK       | Imperative (TypeScript, Python)   | Expressive programming DSL |
| Ansible                | Procedural / Idempotent YAML      | OS config & software setup |
| ArgoCD / Flux          | Declarative GitOps (Kubernetes)   | Continuous reconciliation  |
+-----------------------------------------------------------------------------------------+

2. GitOps Continuous Reconciliation Loop

GitOps Continuous Loop:
[ Git Repository: Desired State (HCL / K8s YAML) ]
                       |
                       v (Continuous Pull & Diff)
[ GitOps Controller (ArgoCD / OpenTofu Agent) ]
                       |
                       v (Reconciles Drift)
[ Live Cloud Infrastructure (AWS / GCP / K8s) ]