SA Pro Lab 02 — Route between VPCs with a Transit Gateway

Scaffold: 3/5. The Transit Gateway, both VPCs and subnets, both VPC attachments, and a custom TGW route table are all built. You write the wiring that makes routing happen: associate and propagate each attachment to the route table, and add the return route in each VPC.

The scenario

You have two VPCs that need to talk to each other, and more coming. The naive answer is VPC peering: fine for one pair, but peerings do not transit, so every new VPC has to peer with every existing one. Ten VPCs is forty-five peerings and forty-five route entries per table to maintain. That is an N-squared mesh, and it does not scale.

A Transit Gateway is the hub. Each VPC attaches once, and the gateway routes between the spokes, so adding the eleventh VPC is one attachment, not ten new peerings. In this lab the gateway is created with default association and default propagation disabled, which means nothing routes automatically. That is deliberate: on a Professional paper the interesting Transit Gateway questions are about explicit routing, where you choose which attachments share a route table and what each one learns.

The requirement

VPC A (10.10.0.0/16) and VPC B (10.20.0.0/16) must be able to reach each other through the Transit Gateway. The gateway’s custom route table must learn both VPC CIDRs, and each VPC’s own route table must send the other VPC’s traffic to the gateway.

What’s provided

Deploying src/template.yaml as shipped succeeds, but the two VPCs cannot reach each other: nothing is associated or propagated to the custom route table, and neither VPC has a route pointing at the gateway.

Your task

Open src/template.yaml and fill in the TODO block with six resources:

If you want the mechanics first, read the walk-through post linked at the bottom.

Run it

# Defaults: stack sa-pro-lab-02, region ap-southeast-2.
./scripts/deploy.sh          # deploys src/template.yaml
./scripts/test.sh            # checks the TGW and VPC route tables
./scripts/teardown.sh        # deletes everything

With the unedited src/template.yaml, test.sh reports the custom route table holding no VPC routes and neither VPC routing to the other: the hub exists, but nothing routes. Fill in the TODO, redeploy, and run the test again.

What success looks like

./scripts/test.sh prints:

  ok: TGW route table has an active route for 10.10.0.0/16
  ok: TGW route table has an active route for 10.20.0.0/16
  ok: rtb-... routes 10.20.0.0/16 via the Transit Gateway
  ok: rtb-... routes 10.10.0.0/16 via the Transit Gateway
PASS: both spokes are associated and propagated, and each VPC routes to the other via the Transit Gateway.

The test never launches an instance, so it stays cheap: it reads the Transit Gateway route table and both VPC route tables and asserts the routes are in place.

If it fails

Reveal the solution

Deploy the complete reference template without editing anything:

SRC=solution ./scripts/deploy.sh && ./scripts/test.sh

What you just learned

Next

The rest of the SA Pro lab track is listed in labs/README-sa-pro.md.