What Is Infrastructure as Code (IaC)?
Infrastructure as Code manages and provisions infrastructure (servers, networks, databases) through machine-readable configuration files, rather than manual...
Published November 19, 2026
Infrastructure as Code (IaC) manages servers, networks and cloud resources through version-controlled configuration files instead of manual clicking. Tools like Terraform, CloudFormation and Ansible apply them repeatably.
The concept
You declare the desired state (a server, a database) in code; the tool compares it with reality and makes changes. The same code can rebuild an environment from scratch.
Benefits: review via pull requests, consistency across dev/staging/prod, audit history and disaster recovery.
Plan then apply
Practical examples
Terraform
resource "aws_instance" "web" {
ami = "ami-0abcdef"
instance_type = "t3.micro"
tags = { Name = "web" }
}Ansible playbook
- hosts: web
tasks:
- name: install nginx
apt: { name: nginx, state: present }Workflow
git commit -am 'add server' && terraform plan && terraform applyCommon mistakes
- Changing resources manually and causing drift.
- Committing secrets or state files.
- No remote, locked state for teams.
Key takeaways
- Infrastructure defined in code.
- Reviewable and repeatable.
- Avoid manual drift.
FAQ
Declarative vs imperative?
Terraform is declarative (what); scripts are imperative (how).
What is drift?
Differences between the real infrastructure and the code.