Chapter 2. How to Manage Your Infrastructure as Code
In Chapter 1, you learned how to deploy your app by using PaaS and IaaS, but it required a lot of manual steps clicking around a web UI. This is fine while you’re learning and experimenting, but managing everything at a company this way—sometimes called ClickOps—quickly leads to problems:
- Deployments are slow and tedious
-
You can’t deploy frequently or respond to problems or opportunities quickly.
- Deployments are error prone and inconsistent
-
You end up with lots of bugs, outages, and late-night debugging sessions. You become fearful and slow to introduce new features.
- Only one person knows how to deploy
-
That person is overloaded and never has time for long-term improvements. If they were to leave or get hit by a bus, everything would grind to a halt.1
Fortunately, these days, there is a better way to do things: you can manage your infrastructure as code (IaC). Instead of clicking around manually, you use code to define, deploy, update, and destroy your infrastructure. This represents a key insight of DevOps: most tasks that you used to do manually can now be automated using code, as shown in Table 2-1.
| Task | How to manage as code | Example | Chapter |
|---|---|---|---|
Provision servers |
Provisioning tools |
Use OpenTofu to deploy a server |
This chapter |
Configure servers |
Server templating tools |
Use Packer to create an image of a server |
This chapter |
Configure ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access