Infrastructure as code (IaC) is the practice of describing servers, networks, databases and other infrastructure in text files that a tool reads and applies automatically. The files are stored in version control, reviewed like software, and used to create or change real resources.
Why it matters
Manual setup produces servers nobody can reproduce exactly. With IaC, an environment can be rebuilt from a repository, differences between staging and production are visible in a diff, and every change has an author and a review trail. It also speeds up disaster recovery, because a lost environment can be recreated from the definitions rather than from memory.
Tools split into declarative ones, where you state the desired end result (Terraform, CloudFormation), and procedural or hybrid ones that describe steps (Ansible scripts, scripted SDK code).
Example
resource "aws_s3_bucket" "assets" {
bucket = "example-assets"
}
Running the tool compares this to reality and creates the bucket only if it does not exist.
Common mistakes
- Making emergency console changes and never updating the code, causing configuration drift.
- Committing secrets such as access keys into the repository.
- Keeping one giant file for all environments so a small change risks production.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.