By the end you'll know
- What high availability means, and the single points of failure in a small network
- How to size a subnet from the number of hosts it needs, and why 254 hosts don't fit in a /24
- Why production networks put a NAT gateway in every zone, and what that costs
- What VPC peering is, the three things it needs, and the two things it can't do
- When to use Transit Gateway instead, and the other ways to connect networks to AWS
Before you start
- You need: the
juniper-ryeprofile from Lesson 4, signed in, and Lessons 8 to 12. Lesson 11's Run Command is how the lab asks its private servers questions. - The script:
ha-lab.shfrom the practice folder'slesson-13. Everything it creates is namedjr-lesson13-*and taggedlesson=13, and itsdeletestep removes it. - How the script talks to AWS: only through the AWS CLI. The few lines of Python in it just turn the CLI's JSON into readable tables and never connect to AWS; boto3, AWS's Python library, comes in Lesson 20.
- To see every call the script makes, put
SHOW=1in front of any step, such asSHOW=1 ./ha-lab.sh build. The lesson's "By hand" section lists them all too. - Where you run things: your own machine, labeled (Your machine).
- Every output below is from two real runs on November 10, 2026. The first run hit a capacity shortage the script didn't handle yet; the second used the fixed script. Each output says which.
Two NAT gateways are the biggest bill in the track so far
The lab costs about $0.13 an hour, almost all of it the two NAT gateways. They bill whole hours, so a run is about 25 cents from credits. Forgotten, the NAT gateways alone are $65.70 a month. Run delete the same day and check every line shows 0.
The short version
- High availability means no single failure takes the service down. In AWS that starts with using at least two Availability Zones for everything.
- Size subnets from host counts: add AWS's 5 reserved addresses, then take the smallest block that fits.
- A NAT gateway lives in one zone, so each zone gets its own, and each zone's private route table points at its own one.
- VPC peering joins two VPCs privately. It needs routes on both sides, it doesn't pass traffic on to a third VPC, and it refuses VPCs whose ranges overlap.
- Transit Gateway is the hub once you have more than a handful of VPCs, or offices and data centers too.
What this lesson costs
| Part | Cost |
|---|---|
| VPCs, 10 subnets, route tables, internet gateway, peering connection | $0 |
| Two NAT gateways, one per zone | $0.045 an hour each, plus $0.045 per GB through them |
| Their two public IPv4 addresses | $0.005 an hour each |
| Three small private servers, with disks | About $0.028 an hour in all |
| Data through the peering connection | Free within one zone; $0.01 per GB each way between zones |
| This lesson | About 25 cents a run, from credits |
| If it were left running | About $93 a month |
What high availability means
A service is highly available when no single failure takes it down. Three words that the Solutions Architect exam keeps apart:
| Term | Means | In the bakery |
|---|---|---|
| High availability | A failure causes at most a brief blip, and the service carries on | A zone fails; the shop keeps serving from the other zone |
| Fault tolerance | A failure causes no interruption at all, usually by running everything twice, all the time | Every order is processed in both zones at once. Costly, and rarely needed by a bakery. |
| Disaster recovery | Getting back after losing a whole Region or the data itself | Lesson 19: backups, a second Region, and how long recovery may take |
The way to find what could take the shop down is to list its single points of failure: anything there's only one of.
| Only one | If it fails | Fixed in |
|---|---|---|
| Server | The shop is down | Lesson 12: an Auto Scaling group behind a load balancer |
| Zone | Everything in it is down: servers, NAT gateway, database | This lesson: every tier in two zones |
| NAT gateway | Every private server, in both zones, loses its way to the internet | This lesson: one per zone |
| Database | Orders can't be saved | Lesson 17: a standby copy in the other zone |
| Region | Everything is down | Lesson 19, for the rare business that needs it |
The design
This is the network the lab builds: the Lesson 8 shape, grown to five tiers in two zones.
Each zone has a /20 block, 4,096 addresses, and the five subnets sit inside it with room to grow. Zone B's ranges are zone A's plus 16 in the third number, so anyone can find the matching subnet in the other zone at a glance. The two /20s use only 8,192 of the VPC's 65,536 addresses, which leaves room for a third zone later.
The design also shows a bastion host in each public subnet: a small server that accepts SSH from one address, as the only way in to the private servers. Lesson 11 replaced that with Session Manager, which needs no open port, so the lab leaves the bastions out.
Sizing a subnet from host counts
Each tier came with a number of hosts it needs. To turn that into a range:
- Add 5, for the addresses AWS reserves in every subnet (Lesson 8): the network address, the router, DNS, one held for the future, and the broadcast address.
- Take the smallest block that holds the total. Blocks come in powers of two: 64, 128, 256, 512, 1,024.
- Start it on a multiple of its own size, so a /22 (four third-number values) starts at 10.0.4.0 or 10.0.8.0, never 10.0.5.0.
| Tier | Hosts needed | Plus 5 | Smallest block | Zone A range | Usable |
|---|---|---|---|---|---|
| Public | 450 | 455 | 512, a /23 | 10.0.0.0/23 | 507 |
| Web | 250 | 255 | 256, a /24 | 10.0.2.0/24 | 251 |
| Java app | 50 | 55 | 64, a /26 | 10.0.3.0/26 | 59 |
| RDS | 680 | 685 | 1,024, a /22 | 10.0.4.0/22 | 1,019 |
| Oracle | 254 | 259 | 512, a /23 | 10.0.8.0/23 | 507 |
Two rows are worth a second look. Oracle needs 254 hosts, and a /24 holds only 251, so 3 hosts push it to a /23, twice the size. That's the reserved addresses at work: on paper a /24 is 256, and a plain network textbook says 254. The web tier is the opposite: 250 hosts in 251 usable addresses leaves one spare. That's tight for an Auto Scaling group that grows under load, and in a real design it's a reason to size up.
The Networking track's Subnets and CIDR lesson has the maths slowly, with a range you can drag.
Is it allowed, and what does it cost?
(Your machine)
cd ~/Apps/aws-practice/lesson-13
chmod +x ha-lab.sh
./ha-lab.sh fence
fence dry-runs the three calls that matter, creating a NAT gateway, creating a peering connection and launching a Free Tier server, and prints the costs in the table above. It creates nothing.
Build it
In the console: VPC > Create VPC > VPC and more, with 2 Availability Zones, and NAT gateways set to 1 per AZ. It builds the same shape with two subnets per zone; add the other tiers under Subnets > Create subnet.
(Your machine)
./ha-lab.sh build
From the second run:
== The shop's VPC, 10.0.0.0/16, from the lesson's design
10 subnets: 5 tiers in each of us-east-2a and us-east-2b
== One NAT gateway in each zone's public subnet (billing starts)
both available
== A private route table for each zone, pointing at that zone's NAT gateway
jr-lesson13-private-routes-a: 4 private subnets in us-east-2a, out through jr-lesson13-nat-a
jr-lesson13-private-routes-b: 4 private subnets in us-east-2b, out through jr-lesson13-nat-b
== A private server in each zone's web subnet (no public address)
jr-lesson13-web-a: t4g.micro in us-east-2a
us-east-2b has no t4g.micro capacity to spare right now: trying the next Free Tier size
jr-lesson13-web-b: t4g.small in us-east-2b
== Waiting for each to check in with Systems Manager, through its zone's NAT gateway
jr-lesson13-web-a: online
jr-lesson13-web-b: online
build made the VPC, the internet gateway and all ten subnets; one public route table for both public subnets; a NAT gateway with its own public address in each public subnet; and a private route table per zone. Then it launched a private server in each zone's web subnet, with Lesson 11's role so Systems Manager can reach it, and no inbound rules at all.
us-east-2b ran out of servers again
Lesson 12 met this first: us-east-2b had no t4g.micro servers to spare. In the first run the script simply stopped, and zone B never got a server. That's the failure high availability is meant to survive, so the script now does what an Auto Scaling group with several instance types does: it tries the next Free Tier size, t4g.small, in the same zone. It costs $0.0168 an hour instead of $0.0084, and zone B got its server.
AWS's own error suggested leaving the zone off the request. That would have worked, and put both servers in us-east-2a, which defeats the design. Keep the zone, change the size.
Check what was built
In the console: VPC > Your VPCs > jr-lesson13-shop-vpc > Resource map draws the subnets, route tables and gateways, joined up.
(Your machine)
./ha-lab.sh show
From the first run:
== The shop's subnets, as built
subnet zone range size free needs
public-a us-east-2a 10.0.0.0/23 512 506 450
web-a us-east-2a 10.0.2.0/24 256 250 250
java-a us-east-2a 10.0.3.0/26 64 59 50
rds-a us-east-2a 10.0.4.0/22 1024 1019 680
oracle-a us-east-2a 10.0.8.0/23 512 507 254
public-b us-east-2b 10.0.16.0/23 512 506 450
web-b us-east-2b 10.0.18.0/24 256 251 250
java-b us-east-2b 10.0.19.0/26 64 59 50
rds-b us-east-2b 10.0.20.0/22 1024 1019 680
oracle-b us-east-2b 10.0.24.0/23 512 507 254
== Route tables
jr-lesson13-public-routes
10.0.0.0/16 -> local
0.0.0.0/0 -> internet gateway
used by 2 subnets
jr-lesson13-private-routes-a
10.0.0.0/16 -> local
0.0.0.0/0 -> NAT gateway nat-0d4d6511d585d2f77
used by 4 subnets
jr-lesson13-private-routes-b
10.0.0.0/16 -> local
0.0.0.0/0 -> NAT gateway nat-03e0a3a2eff505e02
used by 4 subnets
== The NAT gateways
nat-0d4d6511d585d2f77 us-east-2a public address 3.149.104.120
nat-03e0a3a2eff505e02 us-east-2b public address 18.227.125.187
Every subnet's free count is its size minus 5, the reserved addresses, and then minus one for each thing using an address. Both public subnets show 506: their NAT gateway took one. web-a shows 250: its server took one, leaving the tier with exactly the 250 it needs. web-b shows 251 because in this first run, zone B's server never launched.
The route tables are the design's note, made real. There are two private route tables, not one, and the only difference between them is which NAT gateway 0.0.0.0/0 goes to. With one shared private table, every private subnet in both zones would leave through one zone's NAT gateway.
Each zone, its own way out
The route tables say each zone leaves through its own NAT gateway. This step checks it from inside. egress uses Run Command to ask each private server, "What address does the internet see you from?", by fetching https://checkip.amazonaws.com, a page that replies with the address it sees.
In the console: Systems Manager > Run Command > Run command, AWS-RunShellScript, with curl -s https://checkip.amazonaws.com, on each server.
(Your machine)
./ha-lab.sh egress
From the second run:
== Asking each private server: what address does the internet see you from?
jr-lesson13-web-a in us-east-2a: seen as 3.21.74.74 NAT gateway in us-east-2a is 3.21.74.74 match: yes, its own zone's
jr-lesson13-web-b in us-east-2b: seen as 77.112.0.103 NAT gateway in us-east-2b is 77.112.0.103 match: yes, its own zone's
Each server reached the internet as its own zone's NAT gateway. Neither has a public address, yet the internet saw each one at a different address, the one belonging to the NAT gateway beside it. If us-east-2a failed, zone B's servers would carry on reaching the internet, because nothing they need is in 2a.
(The addresses differ from show's because they're from the second run. Each NAT gateway gets a new public address, and delete released them.)
One NAT gateway or two?
The honest trade-off:
| One NAT gateway | One per zone | Regional NAT gateway | |
|---|---|---|---|
| A month, before data, in 2 zones | $32.85 | $65.70 | $65.70, billed per zone it's active in |
| If its zone fails | Every private server loses its way out | Only that zone's servers, which are down anyway | The other zones carry on |
| Data between zones | The other zone's traffic crosses zones: $0.01 per GB each way, on top | Stays in its zone | Stays in its zone |
| Route tables | One private table | One per zone, as this lab built | One, pointing at one gateway |
| Fits | Practice and test environments | Production, and the exam's default answer | Production, with less to manage |
The regional NAT gateway is newer, from November 2025: one gateway for the whole VPC that grows into each zone where it finds servers, with no public subnet needed to hold it. It costs the same per zone, so it's simpler rather than cheaper. The zonal kind the lab built is still what most existing networks, Terraform modules and exam questions use.
Two NAT gateways cost more than the servers behind them
For a small shop, the two NAT gateways are $65.70 a month before a byte goes through them, more than the two servers, the load balancer and the database together. A practice environment can share one; a production one shouldn't. And whichever you build, put a free S3 gateway endpoint in first, so downloads from S3 never pass through a NAT gateway at $0.045 per GB.
Cheaper ways out
Lesson 8 promised to come back to these:
| Option | What it does | Cost | Fits |
|---|---|---|---|
| Gateway endpoint | A route in the private route table straight to S3 or DynamoDB, without the internet | Free | Always, in every VPC that uses S3 or DynamoDB |
| Interface endpoint | A private address in your subnet for one AWS service, like Lesson 11's three for Systems Manager | $0.01 an hour per zone, plus $0.01 per GB | Private subnets that only need a few AWS services |
| NAT instance | An ordinary small server set up to forward traffic | A few dollars a month | Practice, if you'll patch it. It's one server: a single point of failure. |
| IPv6 with an egress-only internet gateway | IPv6 addresses are public, and the egress-only gateway lets them out but not in | Free | Servers whose destinations all speak IPv6 |
Connecting two VPCs: peering
The bakery's office runs a stock system in a VPC of its own, 10.50.0.0/16. VPC peering is a private link between two VPCs, so the shop's servers can reach it by its private address, without the internet. It has three parts: the connection, which one VPC requests and the other accepts; a route on each side; and security groups that allow the traffic.
In the console: VPC > Peering connections > Create peering connection, pick both VPCs, then select it > Actions > Accept request. Then Route tables > each table > Edit routes, on both sides.
(Your machine)
./ha-lab.sh peer
From the first run:
== An office VPC, 10.50.0.0/16, with one private server and no way to the internet
running; port 80 open to 10.0.0.0/16 only
== 1. From jr-lesson13-web-a, ask the office server at 10.50.1.55, before peering
no answer: timed out
== 2. Peer the two VPCs
pcx-0af9aa5280fd8d361: active
asking again, with peering but no routes yet:
no answer: timed out
== 3. Add a route on each side
shop's private route tables: 10.50.0.0/16 -> pcx-0af9aa5280fd8d361
office's route table: 10.0.0.0/16 -> pcx-0af9aa5280fd8d361
asking again:
<p>The office: stock levels for Juniper & Rye</p>
The same question, asked three times:
| When | Answer | Why |
|---|---|---|
| Before peering | Timed out | 10.50.1.55 isn't in the shop's VPC, and the shop's route table had no route for it, except the NAT gateway, which leads to the internet, where private addresses go nowhere |
| Peered, no routes | Timed out | A peering connection on its own carries nothing. Neither VPC's route tables sent anything to it. |
| Routes on both sides | The page | The shop sends 10.50.0.0/16 to the peering connection; the office sends replies for 10.0.0.0/16 back the same way; the office's security group allows port 80 from 10.0.0.0/16 |
The route that won is the most specific one, the same rule as the Networking track's Routing, NAT and private networks. The shop's private tables had 0.0.0.0/0 to the NAT gateway and now 10.50.0.0/16 to the peering connection. Traffic for 10.50.1.55 matches both, and the /16 is more specific than the /0, so it goes through the peering connection.
When the ranges overlap
== 4. A third VPC that reuses 10.0.0.0/16, peered with the shop
status: failed
message: Failed due to incorrect VPC-ID, Account ID, overlapping CIDR range, or VPC Encryption Control posture
deleted the overlapping VPC
AWS accepted the request, then failed it. Its message lists four possible reasons and doesn't say which, but only one applies here: both VPCs use 10.0.0.0/16. A route for 10.0.0.0/16 couldn't say which VPC it meant. There's no fix short of renumbering one of the networks, which means rebuilding everything in it. That's why Lesson 8 said to plan ranges across the whole company, before the first VPC.
What peering can't do
| Rule | Means |
|---|---|
| No overlapping ranges | As the lab just saw |
| Not transitive | If the shop peers with the office, and the office peers with the warehouse, the shop still can't reach the warehouse. It needs its own peering connection. |
| No borrowed gateways | The office can't reach the internet through the shop's NAT gateway, or the shop's VPN |
| Works across accounts and Regions | The other account accepts the request. Across Regions, data is charged as data between Regions. |
| One connection per pair | Ten VPCs that all need each other need 45 peering connections, and routes for each |
Many networks: Transit Gateway
That last row is why peering stops scaling. Transit Gateway is a hub: each VPC attaches to it once, and the hub's own route table decides who reaches whom. Ten VPCs need ten attachments instead of 45 connections. It also connects VPN tunnels and Direct Connect links, so offices and data centers join the same hub.
| Option | Connects | Cost |
|---|---|---|
| VPC peering | Two VPCs, directly | Free; data between zones or Regions is charged |
| Transit Gateway | Many VPCs, VPNs and Direct Connect, through one hub | $0.05 an hour per attachment, $36.50 a month each, plus $0.02 per GB |
| PrivateLink | One service in one VPC, offered to others, without joining the networks. Overlapping ranges are fine. | Interface endpoint prices |
| Site-to-Site VPN | An office or data center, over the internet, encrypted | About $0.05 an hour per connection |
| Direct Connect | A data center, over a private line | Port hours plus data; for large or steady traffic |
The lab doesn't build a Transit Gateway: with two VPCs, peering is the right answer, and a hub would cost $73 a month to show the same page. The exam rule of thumb: a few VPCs, peering; many VPCs or on-premises networks too, Transit Gateway; one service shared out, PrivateLink.
Take it down
In the console: EC2 > Instances > Terminate instance; VPC > Peering connections > Actions > Delete peering connection; NAT gateways > Actions > Delete NAT gateway, then Elastic IPs > Release Elastic IP addresses; then Your VPCs > Actions > Delete VPC for each VPC.
(Your machine)
./ha-lab.sh delete
From the first run:
== Terminated the servers
== Deleted peering connection pcx-0af9aa5280fd8d361
== Deleted the NAT gateways. Their billing stops now.
== Released a NAT gateway's address
== Released a NAT gateway's address
== Deleted role jr-lesson13-ssm-role
== Deleted jr-lesson13-office-vpc and everything in it
== Deleted jr-lesson13-shop-vpc and everything in it
== Left over from this lab (tagged lesson=13)
servers: 0
VPCs: 0
peering connections: 0
IAM role: 0
== Things that bill by the hour, anywhere in us-east-2
servers: 0
NAT gateways: 0
Elastic IPs: 0
The order is Lesson 8's, with two additions: the peering connection goes before either VPC, and the NAT gateways must finish deleting before their addresses can be released. The script waits for that, then waits again for each VPC's network interfaces to disappear, as Lesson 11 learned, before deleting security groups, subnets, route tables, the internet gateway and the VPC.
By hand: every command the script runs
The same lab without the script, in order. It leaves out tags, the capacity fallback and waiting loops; SHOW=1 ./ha-lab.sh build prints the exact calls as they run. (Your machine)
export AWS_PROFILE=juniper-rye AWS_REGION=us-east-2
# The VPC and its internet gateway
VPC=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16 --query Vpc.VpcId --output text)
IGW=$(aws ec2 create-internet-gateway --query InternetGateway.InternetGatewayId --output text)
aws ec2 attach-internet-gateway --internet-gateway-id "$IGW" --vpc-id "$VPC"
# Ten subnets: five tiers in each zone (zone B is zone A plus 16)
mk() { aws ec2 create-subnet --vpc-id "$VPC" --cidr-block "$1" --availability-zone "$2" --query Subnet.SubnetId --output text; }
PUB_A=$(mk 10.0.0.0/23 us-east-2a); PUB_B=$(mk 10.0.16.0/23 us-east-2b)
WEB_A=$(mk 10.0.2.0/24 us-east-2a); WEB_B=$(mk 10.0.18.0/24 us-east-2b)
JAVA_A=$(mk 10.0.3.0/26 us-east-2a); JAVA_B=$(mk 10.0.19.0/26 us-east-2b)
RDS_A=$(mk 10.0.4.0/22 us-east-2a); RDS_B=$(mk 10.0.20.0/22 us-east-2b)
ORA_A=$(mk 10.0.8.0/23 us-east-2a); ORA_B=$(mk 10.0.24.0/23 us-east-2b)
# One public route table for both public subnets
PUB_RT=$(aws ec2 create-route-table --vpc-id "$VPC" --query RouteTable.RouteTableId --output text)
aws ec2 create-route --route-table-id "$PUB_RT" --destination-cidr-block 0.0.0.0/0 --gateway-id "$IGW"
aws ec2 associate-route-table --route-table-id "$PUB_RT" --subnet-id "$PUB_A"
aws ec2 associate-route-table --route-table-id "$PUB_RT" --subnet-id "$PUB_B"
# A NAT gateway in each public subnet, each with its own address
ALLOC_A=$(aws ec2 allocate-address --domain vpc --query AllocationId --output text)
ALLOC_B=$(aws ec2 allocate-address --domain vpc --query AllocationId --output text)
NAT_A=$(aws ec2 create-nat-gateway --subnet-id "$PUB_A" --allocation-id "$ALLOC_A" --query NatGateway.NatGatewayId --output text)
NAT_B=$(aws ec2 create-nat-gateway --subnet-id "$PUB_B" --allocation-id "$ALLOC_B" --query NatGateway.NatGatewayId --output text)
aws ec2 wait nat-gateway-available --nat-gateway-ids "$NAT_A" "$NAT_B"
# A private route table per zone, each pointing at its own zone's NAT gateway
RT_A=$(aws ec2 create-route-table --vpc-id "$VPC" --query RouteTable.RouteTableId --output text)
RT_B=$(aws ec2 create-route-table --vpc-id "$VPC" --query RouteTable.RouteTableId --output text)
aws ec2 create-route --route-table-id "$RT_A" --destination-cidr-block 0.0.0.0/0 --nat-gateway-id "$NAT_A"
aws ec2 create-route --route-table-id "$RT_B" --destination-cidr-block 0.0.0.0/0 --nat-gateway-id "$NAT_B"
for S in "$WEB_A" "$JAVA_A" "$RDS_A" "$ORA_A"; do aws ec2 associate-route-table --route-table-id "$RT_A" --subnet-id "$S"; done
for S in "$WEB_B" "$JAVA_B" "$RDS_B" "$ORA_B"; do aws ec2 associate-route-table --route-table-id "$RT_B" --subnet-id "$S"; done
# Servers: as Lesson 11, a private server with the Systems Manager role, in WEB_A and in WEB_B
# Peering with the office VPC (10.50.0.0/16), then a route on each side
PCX=$(aws ec2 create-vpc-peering-connection --vpc-id "$VPC" --peer-vpc-id "$OFFICE_VPC" \
--query VpcPeeringConnection.VpcPeeringConnectionId --output text)
aws ec2 accept-vpc-peering-connection --vpc-peering-connection-id "$PCX"
aws ec2 create-route --route-table-id "$RT_A" --destination-cidr-block 10.50.0.0/16 --vpc-peering-connection-id "$PCX"
aws ec2 create-route --route-table-id "$RT_B" --destination-cidr-block 10.50.0.0/16 --vpc-peering-connection-id "$PCX"
aws ec2 create-route --route-table-id "$OFFICE_RT" --destination-cidr-block 10.0.0.0/16 --vpc-peering-connection-id "$PCX"
# Taking it down, in this order
aws ec2 terminate-instances --instance-ids "$SERVER_A" "$SERVER_B" "$OFFICE_SERVER"
aws ec2 delete-vpc-peering-connection --vpc-peering-connection-id "$PCX"
aws ec2 delete-nat-gateway --nat-gateway-id "$NAT_A"
aws ec2 delete-nat-gateway --nat-gateway-id "$NAT_B"
aws ec2 wait nat-gateway-deleted --nat-gateway-ids "$NAT_A" "$NAT_B"
aws ec2 release-address --allocation-id "$ALLOC_A"
aws ec2 release-address --allocation-id "$ALLOC_B"
# then, once the VPC has no network interfaces left: security groups, the ten subnets,
# the three route tables, the internet gateway (detach, then delete), and the VPC, as in Lesson 8
In real systems
- Three zones, not two, where the Region has them. Losing one of three leaves two thirds of capacity; losing one of two leaves half, and the survivor must be big enough for everything.
- Address ranges come from a company-wide plan, often managed in AWS's IP Address Manager (IPAM), so no two VPCs ever overlap.
- Database subnets have no route out at all, not even through a NAT gateway. The lab's single private table per zone was a shortcut.
- Many VPCs in one company hang off a Transit Gateway, run by a central network team, with the NAT gateways in one shared VPC instead of every VPC.
- The whole network is Terraform, usually a well-known VPC module where "one NAT gateway per zone" is a single setting. Lesson 28 builds it that way.
Spot the problem
Work out what's wrong before you read the explanation.
"The peering connection is active, and nothing gets through." A team peers the shop's VPC, 10.0.0.0/16, with the office's, 10.50.0.0/16, and the connection shows active. They add a route for 10.50.0.0/16 to the peering connection in the shop's private route tables. The office server's security group allows port 80 from 10.0.0.0/16. Every request from the shop to the office times out. What's wrong? The office's route table has no route back to 10.0.0.0/16, so the office server's replies head for its default route instead of the peering connection, and never arrive. Peering needs a route in the route table of every subnet that takes part, on both sides. The fix: add 10.0.0.0/16 to the peering connection in the office subnet's route table. Then check: does the shop's request get the office page back?
Keep this
| Remember | Why |
|---|---|
| Every tier in at least two zones | A zone can fail, or run out of servers |
| Hosts plus 5, then the next power of two | AWS reserves 5 addresses in every subnet |
| A NAT gateway and a private route table per zone | One zone's failure can't cut off the other |
| Short of capacity: keep the zone, change the size | Moving zones gives up the point of two zones |
| Peering needs routes on both sides | An active connection carries nothing alone |
| Peering is not transitive, and refuses overlaps | Plan ranges company-wide, before the first VPC |
| Many VPCs: Transit Gateway | One attachment each, instead of a connection per pair |
| $32.85 a month per NAT gateway | The free S3 gateway endpoint goes in first |
Where you are now
The bakery's network has five tiers in two zones, every subnet sized from what it holds, and each zone with its own way out, proved from inside the servers. You watched a zone run out of servers and the build keep both zones anyway, connected a second VPC and saw that peering does nothing until the routes exist, and watched AWS refuse a VPC whose addresses overlapped. Next, Lesson 14 gives the shop a real name with Route 53, puts CloudFront in front of it, and turns on HTTPS.
Check yourself
A tier needs 254 hosts. What's the smallest subnet that holds it in AWS?
Why did the lab build two private route tables instead of one?
How did egress prove each zone left through its own NAT gateway?
us-east-2b had no t4g.micro servers. What did the script do?
The peering connection was active, but the office page still timed out. Why?
The shop peers with the office, and the office with the warehouse. Can the shop reach the warehouse?
Why did the third VPC's peering fail?
Key terms
- High availability: no single failure takes the service down for more than a moment.
- Fault tolerance: a failure causes no interruption at all.
- Single point of failure: anything there's only one of, whose loss stops the service.
- Reserved addresses: the 5 addresses AWS keeps in every subnet.
- NAT gateway: lets private servers reach out to the internet, in one zone; the regional kind covers every zone.
- Gateway endpoint: a free route to S3 or DynamoDB that skips the NAT gateway.
- VPC peering: a private connection between two VPCs.
- Transitive: passing traffic on to a third network. Peering isn't.
- Transit Gateway: a hub that connects many VPCs and on-premises networks.
- PrivateLink: sharing one service into other VPCs without joining the networks.
- Site-to-Site VPN and Direct Connect: an encrypted tunnel over the internet, and a private line, from your own network to AWS.
Go deeper
- Networking track: Subnets and CIDR, Routing, NAT and private networks and Cloud networks: VPCs, subnets and gateways.
- AWS: NAT gateways (opens in a new tab), Introducing the regional NAT gateway (opens in a new tab), and VPC peering (opens in a new tab).
- AWS: Transit Gateway (opens in a new tab) and its pricing (opens in a new tab).
- Try: run
build, then add the free S3 gateway endpoint in the console: VPC > Endpoints > Create endpoint, servicecom.amazonaws.us-east-2.s3, type Gateway, with both private route tables ticked. Runshow, and each private table has a new route to a prefix list (pl-...): S3's addresses. The script doesn't know about the endpoint, so delete it under Endpoints > Actions > Delete VPC endpoints before you rundelete.