โ Back to AWS CloudFormation and CDK
๐ AWS CloudFormation and CDK: cheat sheet
๐จ The analogyBuilding a house from a written plan, with a foreman who lists every change before laying a brick.
๐ The regular explanationInfrastructure as code on AWS. A CloudFormation template declares resources, parameters and outputs; CloudFormation creates them as one stack in dependency order, previews updates as change sets, rolls back on failure and detects drift. The CDK generates those templates from TypeScript, Java, Python and other languages.
- You draw one plan of the whole house and put it in the drawer. A friend checks it first, and every old version stays in the drawer too.
- The plan goes to the foreman with one blank filled in, practice. The foreman builds every part on it and treats them all as one house.
- When the house is done, the foreman hands back the facts you need, like the address and where the key is.
- Want the real house? Hand over the same plan with the blank filled in differently. You get the same house again, part for part.
- The foreman reads the plan and notes what needs what. The foundation and the door lock need the plot. The strongroom needs both, and the workshop needs the strongroom.
- Nothing can start before the plot, so the plot comes first.
- The foundation and the door lock don't need each other, so two builders do them at the same time.
- With the foundation and the door lock both done, the strongroom can go up.
- Last comes the workshop, which needs to know where the strongroom is. Taking it all apart later goes in the reverse order.
- You want the shed painted green and the strongroom moved. Before any work, you ask the foreman for a list of exactly what they would do.
- The list says the shed just gets painted, but the strongroom would be knocked down and rebuilt, and whatever is inside would go with it.
- You say go ahead. The shed gets its coat of paint where it stands.
- For the strongroom, the foreman builds a new one first and moves everything that pointed at the old one over to it.
- Then the old strongroom is knocked down, along with whatever was still inside it. The new one starts empty.
- Only the new, empty strongroom is left standing.
- A new job starts. The foreman paints the shed and starts putting up a new workshop.
- The workshop's walls won't go up. That part of the job has failed.
- The foreman undoes the whole job. The shed goes back to its old colour and the half-built workshop is cleared away.
- The house is exactly as it was before, and you get a note saying what went wrong so you can fix the plan.
- A helper takes out the strongroom's alarm by hand, without touching the plan. Now the house and the plan disagree.
- You ask the foreman to check. They walk round the house with the plan and look at every part.
- The shed matches the plan; the strongroom doesn't. The foreman marks it, but doesn't change anything.
- You put the alarm back, and the next check finds the house and the plan agree again.
- You describe what you want in your own words, using a ready-made design, a safe shed with a lock. The draughtsman turns it into the full, detailed plan.
- Before any building, the draughtsman compares the new plan with the last plan the foreman built from, and tells you what would change.
- Then the plan goes to the same foreman as always, who builds it exactly as before.
๐งฉ Key questions
- The plan says the workshop needs to know where the strongroom is. What does the foreman do?
- Builds the strongroom first, then the workshop. The foreman works out the order from what needs what. Parts that don't need each other are built at the same time.
- The change list says the strongroom would be knocked down and rebuilt. Why does that matter?
- Whatever is inside the old strongroom goes with it. That's why you ask for the list first: you see it on paper before anyone picks up a hammer.
- Halfway through a job, the new workshop's walls won't go up. What do you end up with?
- The house exactly as it was before the job, plus a note saying what went wrong. The foreman undoes the whole job, so you never live in half a house.
- A helper takes out the strongroom's alarm by hand. What does the foreman's check do about it?
- Marks the strongroom as not matching the plan, and leaves fixing it to you. The check only reports. You either put the change back or write it into the plan.
- You describe a safe shed in your own words with the kit. Who actually builds it?
- The same foreman, from the full plan the draughtsman drew. The kit only writes the plan. The foreman builds, lists changes and undoes failed jobs, just as before.