Terraform Modules — Challenge
50 minIntermediate
This creates billable resources. Run it in a dev environment and destroy it when you finish. Set a budget alarm first.
You are done when
0 of 5
The goal#
Achieve the same outcome as Terraform Modules, from an empty starting point, without the steps.
The configuration from the previous lab works, and now a second environment needs the same shape with different addresses. Copying the directory is the obvious move and the wrong one — two copies drift, and the drift is discovered during an incident.
A module is how the same definition serves both.
What must be true when you are done#
- A
modules/networkmodule creates a VPC and subnets from inputs, exposing subnet ids as outputs. - A
modules/computemodule places an instance into a subnet it did not create. - The root module wires them together with no hardcoded ids anywhere.
- Calling the network module twice with different CIDRs produces two independent networks.
- You can explain why the compute module never references
aws_vpcdirectly.
Rules#
- Do not open the guided lab until you are finished, or until the same problem has held you up for 20 minutes.
- Documentation is allowed. In the job it is the first thing you open.
- Verify every criterion with a command whose output you can read.
If you get stuck#
- What did you expect, exactly?
- What happened instead — the error text, not a paraphrase?
- Which layer is that error from?
- What is the smallest command that proves the layer below is fine?