Use DescribeRouteTables with an AWS SDK or CLI - Amazon Elastic Compute Cloud

Use DescribeRouteTables with an AWS SDK or CLI

The following code examples show how to use DescribeRouteTables.

CLI
AWS CLI

To describe your route tables

The following describe-route-tables example retrieves the details about your route tables

<userinput>aws ec2 describe-route-tables</userinput>

Output:

{ "RouteTables": [ { "Associations": [ { "Main": true, "RouteTableAssociationId": "rtbassoc-0df3f54e06EXAMPLE", "RouteTableId": "rtb-09ba434c1bEXAMPLE" } ], "PropagatingVgws": [], "RouteTableId": "rtb-09ba434c1bEXAMPLE", "Routes": [ { "DestinationCidrBlock": "10.0.0.0/16", "GatewayId": "local", "Origin": "CreateRouteTable", "State": "active" }, { "DestinationCidrBlock": "0.0.0.0/0", "NatGatewayId": "nat-06c018cbd8EXAMPLE", "Origin": "CreateRoute", "State": "blackhole" } ], "Tags": [], "VpcId": "vpc-0065acced4EXAMPLE", "OwnerId": "111122223333" }, { "Associations": [ { "Main": true, "RouteTableAssociationId": "rtbassoc-9EXAMPLE", "RouteTableId": "rtb-a1eec7de" } ], "PropagatingVgws": [], "RouteTableId": "rtb-a1eec7de", "Routes": [ { "DestinationCidrBlock": "172.31.0.0/16", "GatewayId": "local", "Origin": "CreateRouteTable", "State": "active" }, { "DestinationCidrBlock": "0.0.0.0/0", "GatewayId": "igw-fEXAMPLE", "Origin": "CreateRoute", "State": "active" } ], "Tags": [], "VpcId": "vpc-3EXAMPLE", "OwnerId": "111122223333" }, { "Associations": [ { "Main": false, "RouteTableAssociationId": "rtbassoc-0b100c28b2EXAMPLE", "RouteTableId": "rtb-07a98f76e5EXAMPLE", "SubnetId": "subnet-0d3d002af8EXAMPLE" } ], "PropagatingVgws": [], "RouteTableId": "rtb-07a98f76e5EXAMPLE", "Routes": [ { "DestinationCidrBlock": "10.0.0.0/16", "GatewayId": "local", "Origin": "CreateRouteTable", "State": "active" }, { "DestinationCidrBlock": "0.0.0.0/0", "GatewayId": "igw-06cf664d80EXAMPLE", "Origin": "CreateRoute", "State": "active" } ], "Tags": [], "VpcId": "vpc-0065acced4EXAMPLE", "OwnerId": "111122223333" } ] }

For more information, see Working with Route Tables in the AWS VPC User Guide.

PowerShell
Tools for PowerShell

Example 1: This example describes all your route tables.

Get-EC2RouteTable

Output:

DestinationCidrBlock : 10.0.0.0/16 DestinationPrefixListId : GatewayId : local InstanceId : InstanceOwnerId : NetworkInterfaceId : Origin : CreateRouteTable State : active VpcPeeringConnectionId : DestinationCidrBlock : 0.0.0.0/0 DestinationPrefixListId : GatewayId : igw-1a2b3c4d InstanceId : InstanceOwnerId : NetworkInterfaceId : Origin : CreateRoute State : active VpcPeeringConnectionId :

Example 2: This example returns details for the specified route table.

Get-EC2RouteTable -RouteTableId rtb-1a2b3c4d

Example 3: This example describes the route tables for the specified VPC.

Get-EC2RouteTable -Filter @{ Name="vpc-id"; Values="vpc-1a2b3c4d" }

Output:

Associations : {rtbassoc-12345678} PropagatingVgws : {} Routes : {, } RouteTableId : rtb-1a2b3c4d Tags : {} VpcId : vpc-1a2b3c4d

For a complete list of AWS SDK developer guides and code examples, see Create Amazon EC2 resources using an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.