Infrastructure as Code
In plain English
Plain definition
Infrastructure as Code (IaC) is the practice of defining, provisioning and managing computing infrastructure through machine-readable declarative or imperative configuration files, rather than manual interactive processes, enabling versioned, repeatable and auditable infrastructure changes.
Technical Definition
Infrastructure as Code is a management approach in which infrastructure resources (compute instances, networking, storage, identity policies and platform configuration) are represented as declarative or imperative definitions in a machine-readable language. A control plane or tool reads these definitions and reconciles the described (desired) state against the actual state of the target environment, creating, modifying or removing resources to bring reality into alignment. Declarative tools (for example Terraform, CloudFormation, Pulumi in declarative mode) specify the desired end state and delegate ordering and change calculation to the tool. Imperative tools (for example many Ansible playbooks or shell-based provisioning scripts) specify the sequence of operations to reach that state. Most mature IaC workflows combine both: declarative resource provisioning with imperative configuration management layered on top.
Operational Relevance
IaC underpins repeatable environment creation, disaster recovery, change auditing and drift detection. Because definitions are stored as code, changes can go through the same review, testing and approval gates as application code: pull requests, automated plan/diff output, policy checks and staged rollout. This materially reduces configuration drift between environments and gives operators a traceable record of who changed what, when, and why. It also means that recovering an environment after a failure can, in principle, be reduced to re-applying known-good definitions, provided state data and secrets are also managed correctly.
Architecture Relationship
IaC sits at the provisioning and configuration layer of a platform’s architecture. It typically interacts with three other layers: the underlying provider APIs (cloud provider, hypervisor or hardware orchestration APIs) that it calls to create and mutate resources; a state or inventory layer that records what has been provisioned (a state file, API-backed state store, or the live environment itself for stateless imperative tools); and a delivery layer (CI/CD pipelines, GitOps controllers) that triggers IaC execution on a defined event, such as a merged change. IaC does not replace runtime configuration management or application deployment; it is commonly paired with configuration management tools and application release tooling to cover the full lifecycle from bare resource to running service.
Example
A team defines a virtual network, three compute instances and a load balancer in a declarative configuration file. When a change is proposed — for example, adding a fourth instance — the IaC tool computes a plan describing exactly what will be created, modified or destroyed, and presents that plan for review before anything is applied:
Plan: 1 to add, 0 to change, 0 to destroy.
+ compute_instance.web[3]
id = (known after apply)
instance_type = "m5.large"
subnet_id = "subnet-0a1b2c3d"
The reviewer checks the plan output against the intended change before approval, rather than trusting an unverified manual action performed directly against the live environment.
Common Misunderstanding
A frequent misunderstanding is treating IaC as inherently safe simply because it is code. IaC definitions can still describe destructive or insecure changes; the tool will faithfully execute whatever the definition specifies, including deleting resources or opening broad network access, unless separate safeguards such as plan review, policy-as-code checks, state locking and least-privilege execution credentials are also in place. Writing infrastructure as code changes how changes are expressed and reviewed; it does not by itself guarantee correctness, security or recoverability. Another common error is conflating configuration management (maintaining state on already-running systems) with IaC (provisioning the systems themselves); the two are complementary but address different lifecycle stages.
Related Terms
- Configuration Management
- Declarative Provisioning
- GitOps
- State Drift
- Policy as Code
Further Reading
Refer to the KBY Technologies Infrastructure as Code technology reference for platform-specific documentation and current tooling guidance. Because tool behaviour, default permissions and provider APIs change between releases, confirm the specific tool version and permission model in use before relying on version-specific operational detail.