What Is Infrastructure as Code
Describing servers, networks, and databases in version-controlled files instead of clicking through a console.
On this page5 sections
Infrastructure as Code (IaC) means describing your servers, networks, and databases in files - checked into version control - rather than clicking buttons in a cloud provider's web console.
The problem with clicking
Manually clicking through a console to create a server works fine, right up until:
- Nobody can tell you exactly what was configured, or why, six months later.
- Rebuilding the same environment for staging means remembering (or re-discovering) every single click.
- There's no diff, no review, and no record of who changed what.
Every one of those problems disappears once "how the infrastructure is configured" is a text file sitting in the same repository as the application code.
Declarative, not imperative
Most IaC tools are declarative: you describe the end state you want ("there should be one web server, this size, in this region"), not the step-by-step commands to get there. The tool itself figures out what needs to change to reach that state - including doing nothing at all, if reality already matches.
Idempotency
That leads to the single most important property an IaC tool needs: idempotency. Running the same configuration twice should produce the exact same result as running it once - never a second copy, never an error because "it already exists." You can safely re-run it after a crash, after a doubt, or just as routine maintenance, and trust it will only change what actually needs to change.
Why it matters
- Reviewable - a proposed infrastructure change is a pull request diff, read and approved like any code change.
- Repeatable - standing up an identical staging environment is running the same files again, not re-deriving tribal knowledge.
- Disaster recovery - if a server vanishes, "rebuild it" means rerunning the config, not reconstructing a manual setup from memory.
Try it
touch main.tf
When you're ready, hit Mark complete and move to the next lesson.
Challenge
Create an empty file named main.tf - where Terraform configuration lives.
Want to experiment first? Try things in the practice terminal (opens in a new tab), then enter the command that solves the task here.
Quiz
Lock in the concepts. Score at least 80% to mark the lesson complete.
Done with this one?
Skipped the challenge? You can mark the lesson complete by hand.