Lesson 2 · Unit 04
Infrastructure as code, and cost
Declare, plan, apply; state and drift; a monthly bill from its parts
What you practise
- Declare, plan, apply
- State and drift
- A monthly bill estimated from its parts
- Idle resources and data transfer as the usual surprises
Try a question from this lesson
Pick one
An engineer built production by clicking in a console for two years, then left. The team must now build an identical staging copy. What is the real problem?
Correct answer
Nobody can say exactly what production is
Why
Hundreds of settings exist only in the live system and in one person's memory. Without a written description there is nothing to copy, review or roll back to. A file fixes that.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Declare, plan, apply
Infrastructure as code: a file declares what should exist. It lists the result, not the steps.
The tool compares the file with what exists and prints a plan: what it would create, change and destroy.
You read the plan. Apply then makes the API calls.
The file lives in git, so every change to production is reviewed, has history, and can be repeated for a second environment.
AWS: CloudFormation, where the plan is called a change set. Across providers, Cloudflare included: Terraform.
declare --> plan --> apply
(file) (diff) (API calls)Concept
State and drift
The tool keeps state: a record of which real resource belongs to each declaration.
Drift is reality changed by hand, so that it no longer matches the file. The next plan shows the difference, and apply would put things back as the file says.
You then choose: write the change into the file, or let apply undo it.
Lose the state and the tool no longer knows what it owns.
CloudFormation calls the check drift detection. Terraform compares state with reality on every plan.
10 more exercises in the app
- 3× multiple choice
- 1× order the lines
- 2× true or false
- 1× fill the blanks
- 2× type the answer
- 1× match the pairs
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.