AdvancedTopic 103 of 104Software & Computing
Infrastructure as code
Servers and networks defined in version-controlled files and applied automatically.
In depth
IaC defines servers, networks and services in declarative code (Terraform, CloudFormation, Pulumi) or configuration tools (Ansible), stored in version control, reviewed and applied automatically. Benefits: repeatability, drift detection, auditability, fast recovery.
Key points
- Immutable infrastructure
- State files
- GitOps
ExampleA Terraform file recreates an entire cloud environment in minutes.
What is Infrastructure as code?
Servers and networks defined in version-controlled files and applied automatically.
Why is it important to understand infrastructure as code?
Infrastructure as code makes server setup repeatable and reviewable, which reduces configuration drift and manual errors.
What is configuration drift?
The gradual difference between the intended configuration and the actual state of servers, usually caused by manual changes.
Why keep infrastructure in version control?
History, review and reproducibility come for free, and it is clear who changed what and when.
How is Infrastructure as code used in practice?
Typical applications include defining a server and its network in a file that is reviewed like code, recreating a test environment identically each time it is needed and rolling back a change to a cloud network by reverting a commit.
What should I learn before Infrastructure as code?
Study "Observability" first (topic 102 of 104 in Software & Computing). It covers the groundwork this topic builds on.
What are the key points of Infrastructure as code?
Immutable infrastructure. State files. GitOps.
Can you give an example of Infrastructure as code?
A Terraform file recreates an entire cloud environment in minutes.
What comes after Infrastructure as code?
The next topic is "Formal verification", which builds directly on this one.
How difficult is Infrastructure as code?
It is classed as Advanced in Software & Computing (topic 103 of 104). It is an advanced topic. It assumes you are comfortable with the intermediate topics in Software & Computing.