đĄ Intermediate: The Modular Metropolis#
After fixing the Foundation Stones, CloudHaven is thriving! The city has grown to three districts, and the Guild decided to refactor the infrastructure into reusable modules. A senior engineer started the work using Test-Driven Development - writing tests first, then implementing. But they were called away before finishing, leaving behind working tests... and buggy code that doesn't match them. Your mission: fix the bugs, complete the integration test, and deploy the infrastructure.
â° Deadline#
Wednesday, 4 February 2026 at 23:59 CET
âšī¸ You can still complete the challenge after this date, but points will only be awarded for submissions before the deadline.
đŦ Join the discussion#
Share your solutions and questions in the challenge thread in the Open Ecosystem Community.
đ¯ Objective#
By the end of this level, you should have:
- All tests of the districts module pass
- A completed integration test that applies infrastructure against the mock GCP API to verify end-to-end functionality
- Three districts deployed with correctly configured infrastructure (vaults and ledgers)
âšī¸ Important: The tests are correct - they define the expected behavior. Your job is to fix the implementation to match what the tests expect. Don't modify existing tests unless a comment tells you to; let the tests guide your fixes.
đ§ What You'll Learn#
- OpenTofu module structure & testing with
tofu test - Test-Driven Development (TDD) workflow
- Input validation
- How to use the
movedblock for refactoring infrastructure
đ§° Toolbox#
Your Codespace comes pre-configured with the following tools to help you solve the challenge:
tofu: The OpenTofu CLI for infrastructure provisioninggcp-api-mock: A mock GCP API running locally to simulate cloud resources without real cloud costs
â ī¸ Note: The mock API only supports Cloud Storage and Cloud SQL, and only the functions needed for this challenge have been properly tested.
â How to Play#
1. Start Your Challenge#
đ First time? Check out the Getting Started Guide for detailed instructions on forking, starting a Codespace, and waiting for infrastructure setup.
Quick start:
- Fork the repo
- Create a Codespace
- Select "đ Adventure 02 | đĄ Intermediate (The Modular Metropolis)"
- Wait ~2 minutes for the environment to initialize (
Cmd/Ctrl + Shift + PâView Creation Logto view progress)
2. Access the GCP API Mock UI#
- Open the Ports tab in the bottom panel
- Find the GCP API Mock row (port
30104) and click the forwarded address - This UI lets you explore the mock cloud resources (buckets, databases) created by your OpenTofu configuration
3. Fix the Configuration#
The Guild's senior engineer started refactoring the infrastructure into modules but left before finishing. The tests are failing, and the configuration has bugs.
Review the đ¯ Objective section to understand what a successful solution looks like.
Where to Look#
All OpenTofu files are located in:
adventures/02-building-cloudhaven/intermediate/
âââ main.tf # Provider and backend configuration
âââ variables.tf # Input variables
âââ districts.tf # Module calls for each district
âââ outputs.tf # Infrastructure outputs
âââ moved.tf # Resource migration blocks
âââ modules/district/ # The district module (fix bugs here)
â âââ main.tf # Locals and tier configuration
â âââ variables.tf # Input validation
â âââ vault.tf # Storage bucket resource
â âââ ledger.tf # Cloud SQL resource
â âââ outputs.tf # Module outputs
â âââ tests/ # Module tests (read these!)
âââ tests/
âââ integration.tftest.hcl # Complete this test
đĄ Tip: Run
make testto see which tests fail and start fixing bugs.
Apply Your Changes#
After making your fixes:
make test # Run all tests - should pass
make apply # Apply infrastructure to mock GCP API
Helpful Documentation#
4. Verify Your Solution#
Once you think you've solved the challenge, it's time to verify!
Run the Smoke Test#
Run the provided smoke test script from the challenge directory:
./smoke-test.sh
If the test passes, your solution is very likely correct! đ
Complete Full Verification#
For comprehensive validation and to officially claim completion:
- Commit and push your changes to your fork
- Manually trigger the verification workflow on GitHub Actions
- Share your success with the community
đ Need detailed verification instructions? Check out the Verification Guide for step-by-step instructions on both smoke tests and GitHub Actions workflows.