CompCode Academy

Lesson 2 of 4 · Free to read

Exercises

Exercises — Infrastructure as Code (Terraform + Pulumi)

Watch & learn

Course video

Open on YouTube
Complete Terraform Course — Beginner to Pro — Infrastructure as code mental model.

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

  1. cd code-examples/python/terraform_lab/.
  2. Open main.tf. Add a task_service resource.
  3. terraform init && terraform plan && terraform apply.

Success criteria

  • apply succeeds.
  • terraform.tfstate shows 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

  1. After Exercise 1's apply, manually edit state-overrides.json to simulate an out-of-band change.
  2. Run terraform plan — observe the drift report.
  3. 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

  1. Open pulumi-version/.
  2. Implement the same task_service resource.
  3. 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.

New free lessons and course updates. Unsubscribe from any email.