Infrastructure as Code, commonly abbreviated as IaC, is the practice of defining and managing computing infrastructure through machine-readable configuration files rather than through manual processes or interactive tools. When an engineer provisions a server by clicking through a web console, that action is not recorded in any repeatable format. When the same engineer writes a configuration file that describes the desired server, that file can be stored, reviewed, shared, and executed consistently across environments.
The phrase infrastructure in this context covers everything below the application layer: virtual machines, containers, networking components such as subnets and firewalls, load balancers, storage volumes, databases, identity and access policies, and the relationships between all of these. IaC treats these components as software artifacts, applying the same discipline to infrastructure that developers apply to application code.
A key distinction exists between two broad styles of IaC. Declarative IaC describes the desired end state of infrastructure. The tool figures out how to reach that state. Imperative IaC describes the sequence of steps needed to reach a state. The engineer specifies the procedure. Most modern IaC tools favor the declarative model because it is easier to reason about, less error-prone, and naturally idempotent, meaning you can apply the same configuration repeatedly and get the same result without side effects.
Idempotency is one of the most important properties in IaC. A configuration that is applied once should produce the same outcome as a configuration applied ten times. This property enables safe re-application of configurations after changes, drift correction, and automated remediation without fear of unintended consequences.
Another central concept is the idea of the configuration as the single source of truth. Rather than relying on documentation, tribal knowledge, or manually maintained runbooks to understand what infrastructure exists, teams consult the IaC repository. The code describes not just what was provisioned but also the intended state of the system at any point in time.
Infrastructure as Code (IaC): The practice of managing and provisioning infrastructure through version-controlled, machine-readable configuration files, enabling consistent, repeatable, and auditable infrastructure operations.
Consider a mid-size SaaS company that runs its web application on three environments: development, staging, and production. Before adopting IaC, a senior engineer manually configured each environment through a cloud console, taking notes in a shared document. When the staging environment needed to match a new production configuration, the engineer spent hours comparing settings and making manual changes, sometimes introducing inconsistencies.
After adopting IaC, the team wrote a single set of configuration files describing their infrastructure. They parameterized environment-specific values such as instance sizes and replica counts. Applying the configuration to staging meant running a single command. Differences between environments were intentional and documented in the code, not accidental and hidden in a console.
- IaC defines infrastructure through machine-readable files rather than manual processes.
- Infrastructure covers servers, networking, storage, databases, and access policies.
- Declarative IaC describes desired state; imperative IaC describes steps to reach state.
- Idempotency ensures repeated application of a configuration produces the same outcome.
- The IaC repository serves as the single source of truth for infrastructure state.