Lesson 2 of 4 · Free to read
Exercises
Exercises — Infrastructure as Code (Terraform + Pulumi)
Watch & learn
Course video
Keep a prompt log while you work. Speed without a trail is not a skill — it is luck.
Exercise 1 — Author a tiny module
Goal: write a Terraform module that creates a "task service" object (using the fake provider). Time: 30 minutes Level: foundational
Steps
cd code-examples/python/terraform_lab/.- Open
main.tf. Add atask_serviceresource. terraform init && terraform plan && terraform apply.
Success criteria
applysucceeds.terraform.tfstateshows the resource.
AI prompt hints
- "Write a Terraform module with a variable for replicas; output a diff only."
Exercise 2 — Surface drift
Goal: simulate drift, then surface it with plan. Time: 20 minutes Level: intermediate
Steps
- After Exercise 1's apply, manually edit
state-overrides.jsonto simulate an out-of-band change. - Run
terraform plan— observe the drift report. - Decide: re-apply or import?
Success criteria
- Drift visible in plan output.
- A 2-line decision note.
Exercise 3 — Compare Pulumi side-by-side
Goal: rewrite the Terraform module in Pulumi Python; compare verbosity, readability, debugging. Time: 35 minutes Level: intermediate
Steps
- Open
pulumi-version/. - Implement the same
task_serviceresource. - Compare the two implementations.
Success criteria
- Both implementations exist.
- A 3-line comparison in
compare.md.
AI prompt hints
- "Translate this Terraform module to Pulumi Python; output the file only."
Solution sketch
Pulumi wins on conditionals; Terraform wins on ecosystem breadth.