How to get instance's route table id using CLI?
The route table is associated with VPC, which is associated with the instance.

Given $id shell variable has the instance ID, e.g.

id=i-0xyz # Replace i-0xyz with the real Instance ID.


here is the shell command to get VPCs associated with the instance and assign to $vpcs variable:

vpcs=$(aws ec2 describe-instances --instance-id $id --query 'Reservations[].Instances[].NetworkInterfaces[].VpcId' --output text)


Then to list the route tables associated with VPC, run:

aws ec2 describe-route-tables --filters "Name=vpc-id,Values=$vpcs"


To get just the route ids, add: --query "RouteTables[].RouteTableId[]" parameter.