A route table is a list of routes. Each route is a destination (a block of addresses) and a target (where to send traffic for it). Every subnet uses exactly one table.
A new VPC has a main route table with one route, 10.0.0.0/16 → local: anything addressed inside the VPC is delivered inside the VPC. A subnet with no table of its own uses the main one.
The market's public and private subnets will need different routes, so each kind gets its own table: public and private.
Creating a table
RT=$(aws ec2 create-route-table --vpc-id $VPC --tag-specifications 'ResourceType=route-table,Tags=[{Key=Name,Value=public}]' --query RouteTable.RouteTableId --output text)A new table starts with the local route and nothing else.
Associating subnets
Association takes the subnet's id, so find it by its Name first:
SUBNET=$(aws ec2 describe-subnets --filters Name=tag:Name,Values=public-a --query "Subnets[0].SubnetId" --output text)aws ec2 associate-route-table --route-table-id $RT --subnet-id $SUBNETpublic-a now uses public instead of the main table. Repeat the last two commands for each subnet. One table can serve many subnets; a subnet has only one table.
Reading a table
aws ec2 describe-route-tables --filters Name=tag:Name,Values=public --query "RouteTables[0].Routes"The answer lists each route's DestinationCidrBlock and its target (GatewayId is local for the local route).