Services

Resources

Company

IaC (infrastructure as code)

Infrastructure as code (IaC) is the practice of defining infrastructure, such as networks, virtual machines, databases and IAM (identity and access management) policies, in text files instead of console clicks. The files live in version control, go through code review and are applied by a tool such as Terraform. The same code can rebuild the same environment repeatedly.

How it works

You declare the resources you want. The tool compares that declaration with a state file that records what it created earlier, and with the real cloud APIs. It then computes a plan. For example, terraform plan might report Plan: 3 to add, 1 to change, 0 to destroy. terraform apply executes that plan and updates the state. Modules let teams reuse one VPC (virtual private cloud) or cluster definition across dev, staging and production.

Why it matters in production

IaC makes infrastructure changes reviewable, repeatable and reversible. It cuts the drift between environments that causes "works in staging" incidents. It also makes disaster recovery faster, because a lost environment can be recreated from code. State files need protection, since they can hold secrets and a corrupted state blocks every change.

See also

On the One2N blog

References

  1. What is Terraform? (HashiCorp developer docs)

Comic about infrastructure as code: Kai opens network port 8443 on the test servers by clicking in a web console; nobody writes it down, the live servers keep 8443 shut, and the release fails on live; the setup moves to a servers.tf file with open_door = 8443, reviewed and approved like code; a tool applies the same file to test and live, the release passes, and every change has a history.