Route Tables#
We’ve attached an internet gateway to our VPC, but nothing tells the subnets it exists or when to use it.
To do that we need a route, and routes live in the creatively named route table. It is literally just a list of routes.
We can add a special kind of route, a “default route,” to our table. It is a catch-all rule that says:
“If you don’t have a specific address for something, look here.”
This lets us create rules for things we care about (like local traffic). If we don’t have a specific rule for something, we send it to the internet. When we’re done with this lesson, our VPC will look like this:

how to create to gateway for internet access#
Create a route table that sends public subnet traffic to the internet gateway.
- Navigate to “VPC” using the search bar in the AWS Console.
- Click on “Route tables” in the left-hand menu.
- Click the orange “Create route table” button at the top right.
- Name the new route table
patientping-public-rt, select ourpatientpingVPC, and click “Create route table.” - Click the “Actions” dropdown button at the top right, then click “Edit subnet associations.”
- Select both
patientping-public-aandpatientping-public-b(and only those!), then click “Save associations.” - Back in the list of route tables, select
patientping-public-rtagain, and click “Actions” → “Edit routes.” - Click “Add route.”
- Set the destination to
0.0.0.0/0. This “everything CIDR” is what makes it the default route. - For the target, select “Internet Gateway.” It should open a new input field, where you can select the gateway you just created (
patientping-igw). - Click “Save changes.”
Whew! Finally, we have “public” subnets that can connect to the internet.
Take a moment to review your “Internet gateways” and “Route tables” in the VPC dashboard.
Tip#
If you want to use the CLI instead, here’s the command structure:
# Create a route table
aws ec2 create-route-table --vpc-id <vpc-id> --tag-specifications 'ResourceType=route-table,Tags=[{Key=Name,Value=<name>}]'
# Associate the route table with a subnet (run once per public subnet)
aws ec2 associate-route-table --route-table-id <rt-id> --subnet-id <subnet-id>
# Add a route to the route table
aws ec2 create-route --route-table-id <rt-id> --destination-cidr-block 0.0.0.0/0 --gateway-id <igw-id>