Infrastructure as code (IaC)
Also called IaC.
Defining servers, networks, databases and other cloud resources in code files that are versioned and applied automatically, instead of setting them up by hand.
Last updated
What it is.
With IaC, the cloud setup lives in files in the repository. A tool reads them, compares them with what exists and makes the changes. The same files can create a new environment, rebuild a broken one or show exactly what will change before it happens.
Changes go through code review and the CI/CD pipeline like any other code, so there is a history of who changed what and why.
Why it matters
Hand-built infrastructure drifts, is hard to copy and is lost when the one person who built it leaves. IaC makes environments repeatable, makes disaster recovery practical and gives auditors a clear record of changes. It is also a key part of a clean handover to the client.
In a product build
We define every environment in code from the start, keep secrets in a secrets manager rather than in the files, review planned changes before they are applied and lock production so changes only come through the pipeline.
Common mistakes.
- 01
Fixing things by hand in the console, so the code no longer matches reality.
- 02
Storing secrets in IaC files in the repository.
- 03
One giant config for everything, so a small change risks the whole stack.
Related terms.
- CI/CD (continuous integration and delivery)An automated pipeline that builds and tests every code change (CI) and then releases it to users in a repeatable way (CD).
- Kubernetes (K8s)An open source platform that runs and manages containers across a group of machines: starting them, restarting them, scaling them and routing traffic to them.
- Container (software)A package that holds an application and everything it needs to run, isolated from other software on the same machine.
- IaaS (infrastructure as a service)Renting raw computing, storage and networking from a cloud provider, while you manage everything that runs on it.
- Blue-green deploymentA release method that runs two identical production environments and switches all traffic from the old one to the new one in one step.
Guides and pages
Browse the full glossary or read answers to common questions.