A new VPC is closed to the internet. Two pieces open it:
| Piece | Job |
|---|---|
| internet gateway | the VPC's door to the internet |
| route table | the signs: where traffic for each address goes |
A route sends a range of addresses somewhere. Every route table starts with one, local, for traffic inside the VPC. Add a route for 0.0.0.0/0 (everywhere else) to the internet gateway, give that route table to a subnet, and the subnet is public.
text
10.0.0.0/16 -> local ← inside the VPC
0.0.0.0/0 -> igw-0123456789abcdef0 ← everything else: the internetNew command
aws ec2 create-route
Adds a route to a route table. Here: everything outside the VPC goes to the internet gateway.
Usageaws ec2 create-route --route-table-id rtb-id --destination-cidr-block 0.0.0.0/0 --gateway-id igw-id
Example
aws ec2 create-route --route-table-id rtb-0123456789abcdef0 --destination-cidr-block 0.0.0.0/0 --gateway-id igw-0123456789abcdef0
A private subnet has no such route. Its servers can still get updates through a NAT gateway: it sits in a public subnet and lets private servers reach out, while nothing from the internet can reach in. It costs money every hour, even when idle.