Glossary termPractice

Infrastructure as Code

Also known as: IaC

Practice of defining and provisioning servers, networks and other infrastructure through machine-readable files rather than manual configuration.

Infrastructure as code (IaC) treats the setup of computing infrastructure as a software problem. Instead of clicking through consoles or typing commands on individual machines, engineers write definition files that describe servers, networks, load balancers, databases, permissions and other resources. A tool reads those files and creates or changes the real infrastructure to match. Because the definitions live in version control, changes can be reviewed, tested, repeated in several environments and rolled back, giving infrastructure the same audit trail and collaboration workflow as application code.

IaC tools follow two broad styles. Declarative tools, such as Terraform, OpenTofu and AWS CloudFormation, describe the desired end state and work out the steps needed to reach it, often showing a plan of changes before applying them. Imperative approaches describe the steps directly. The roots of the idea lie in configuration tools such as CFEngine, first released by Mark Burgess in 1993, and the practice spread widely with cloud computing, where every resource can be created through an API. Terraform, released by HashiCorp in 2014, became one of the most widely used tools across cloud providers.

Good IaC relies on idempotence: applying the same definition twice should produce the same result without unintended side effects. A persistent challenge is drift, when someone changes infrastructure manually and the real state no longer matches the code. Tools that store state must also protect it, since state files can contain sensitive values. IaC underpins immutable infrastructure and GitOps, and it has made infrastructure reproducible enough that whole environments can be created for a single test and destroyed afterward.

Key points

  • Infrastructure definitions kept in version control can be reviewed, repeated and rolled back like application code.
  • Declarative IaC tools describe a desired end state and calculate the changes needed to reach it.
  • Drift occurs when manual changes cause real infrastructure to diverge from its code definition.
  • The practice grew with cloud computing, where every resource can be created through an API.

Related entries

Technology

Terraform

DevOps

Infrastructure-as-code tool from HashiCorp that provisions cloud and on-premises resources from declarative configuration files.

Technology

OpenTofu

DevOpsFOSS

Open-source infrastructure-as-code tool forked from Terraform in 2023 after HashiCorp moved Terraform to a source-available license.

Technology

Ansible

DevOpsFOSS

Open-source, agentless automation tool that configures servers, deploys software and orchestrates IT tasks using YAML playbooks run over SSH.

Glossary term

Discipline and tooling for establishing and maintaining a known, consistent state for systems, software and their settings over time.

Glossary term

Approach in which servers and other components are never modified after deployment; changes are made by replacing them with freshly built versions.

Glossary term

GitOps

DevOps

Operational model in which a Git repository holds the declared state of infrastructure and applications, and automated agents keep systems in sync with it.

Glossary term

Idempotence

ProgrammingDevOps

Property of an operation that produces the same result whether it is applied once or many times, important for safe retries and automation.

Glossary term

Delivery of computing resources such as servers, storage, databases and software over a network on demand, with users paying for what they use.

Featured in guides

Referenced by

Other entries that discuss or point to Infrastructure as Code.