Courses / Cloud and DevOps Interview Prep / Chapter 5
Module 3 · Pipelines and infrastructure as code · Chapter 5 of 13
Infrastructure as Code: State, Drift and Policy Checks
Builds on CI/CD Pipelines: Verify, Release Gradually, Roll Back. Next up: Kubernetes in Production: Debugging Pods, Services and Rollouts.
Part 1 · Where infrastructure state lives
State is a map from code to real objects
Infrastructure as code lets a team review, repeat and undo changes to tables, queues and networks the way it does for application code. The tool that applies those changes still has to remember which real objects belong to which lines of code.
Infrastructure as code (IaC) means you describe the resources you want in text files and a tool makes the cloud match. What you write is the desired state. What exists in the account right now is the actual state. The tool cannot find "the table I created last week" by guessing, so it keeps a record called the state: for every resource in your code, the id of the real object it created and the attributes it saw.
On the next run the tool reads that record, asks the cloud for the current values, compares them with your code and works out the difference. Without the record, a resource you rename in code would look brand new, and the old object would be left running and billed.
Three tools keep that record in three different places.
| Tool | You write |
|---|