Skip to main content

route_tables

Creates, updates, deletes, gets or lists a route_tables resource.

Overview

Nameroute_tables
TypeResource
Idaws.ec2.route_tables

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
associationsstringThe associations between the route table and your subnets or gateways.
owner_idstringThe ID of the Amazon Web Services account that owns the route table.
propagating_vgwsstringAny virtual private gateway (VGW) propagating routes.
route_table_idstringThe ID of the route table.
routesstringThe routes in the route table.
tagsstringAny tags assigned to the route table.
vpc_idstringThe ID of the VPC.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_route_tablesselectregionNextToken, MaxResults, DryRun, RouteTableId, FilterDescribes your route tables. The default is to describe all your route tables. Alternatively, you can specify specific route table IDs or filter the results to include only the route tables that match specific criteria. Each subnet in your VPC must be associated with a route table. If a subnet is not explicitly associated with any route table, it is implicitly associated with the main route table. This command does not return the subnet ID for implicit associations. For more information, see Route tables in the Amazon VPC User Guide.
create_routeinsertRouteTableId, regionDestinationPrefixListId, VpcEndpointId, TransitGatewayId, LocalGatewayId, CarrierGatewayId, CoreNetworkArn, OdbNetworkArn, DryRun, DestinationCidrBlock, GatewayId, DestinationIpv6CidrBlock, EgressOnlyInternetGatewayId, InstanceId, NetworkInterfaceId, VpcPeeringConnectionId, NatGatewayIdCreates a route in a route table within a VPC. You must specify either a destination CIDR block or a prefix list ID. You must also specify exactly one of the resources from the parameter list. When determining how to route traffic, we use the route with the most specific match. For example, traffic is destined for the IPv4 address 192.0.2.3, and the route table includes the following two IPv4 routes: 192.0.2.0/24 (goes to some target A) 192.0.2.0/28 (goes to some target B) Both routes apply to the traffic destined for 192.0.2.3. However, the second route in the list covers a smaller number of IP addresses and is therefore more specific, so we use that route to determine where to target the traffic. For more information about route tables, see Route tables in the Amazon VPC User Guide.
create_route_tableinsertVpcId, regionTagSpecification, ClientToken, DryRunCreates a route table for the specified VPC. After you create a route table, you can add routes and associate the table with a subnet. For more information, see Route tables in the Amazon VPC User Guide.
associate_route_tableupdateRouteTableId, regionGatewayId, PublicIpv4Pool, DryRun, SubnetIdAssociates a subnet in your VPC or an internet gateway or virtual private gateway attached to your VPC with a route table in your VPC. This association causes traffic from the subnet or gateway to be routed according to the routes in the route table. The action returns an association ID, which you need in order to disassociate the route table later. A route table can be associated with multiple subnets. For more information, see Route tables in the Amazon VPC User Guide.
disassociate_route_tableupdateAssociationId, regionDryRunDisassociates a subnet or gateway from a route table. After you perform this action, the subnet no longer uses the routes in the route table. Instead, it uses the routes in the VPC's main route table. For more information about route tables, see Route tables in the Amazon VPC User Guide.
replace_route_table_associationreplaceAssociationId, RouteTableId, regionDryRunChanges the route table associated with a given subnet, internet gateway, or virtual private gateway in a VPC. After the operation completes, the subnet or gateway uses the routes in the new route table. For more information about route tables, see Route tables in the Amazon VPC User Guide. You can also use this operation to change which table is the main route table in the VPC. Specify the main route table's association ID and the route table ID of the new main route table.
replace_routereplaceRouteTableId, regionDestinationPrefixListId, VpcEndpointId, LocalTarget, TransitGatewayId, LocalGatewayId, CarrierGatewayId, CoreNetworkArn, OdbNetworkArn, DryRun, DestinationCidrBlock, GatewayId, DestinationIpv6CidrBlock, EgressOnlyInternetGatewayId, InstanceId, NetworkInterfaceId, VpcPeeringConnectionId, NatGatewayIdReplaces an existing route within a route table in a VPC. You must specify either a destination CIDR block or a prefix list ID. You must also specify exactly one of the resources from the parameter list, or reset the local route to its default target. For more information, see Route tables in the Amazon VPC User Guide.
delete_route_tabledeleteRouteTableId, regionDryRunDeletes the specified route table. You must disassociate the route table from any subnets before you can delete it. You can't delete the main route table.
delete_routeexecRouteTableId, regionDestinationPrefixListId, DryRun, DestinationCidrBlock, DestinationIpv6CidrBlockDeletes the specified route from the specified route table.
disable_vgw_route_propagationexecGatewayId, RouteTableId, regionDryRunDisables a virtual private gateway (VGW) from propagating routes to a specified route table of a VPC.
enable_vgw_route_propagationexecGatewayId, RouteTableId, regionDryRunEnables a virtual private gateway (VGW) to propagate routes to the specified route table of a VPC.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
AssociationIdstringThe association ID.
GatewayIdstringThe ID of the virtual private gateway that is attached to a VPC. The virtual private gateway must be attached to the same VPC that the routing tables are associated with.
RouteTableIdstringThe ID of the route table. The routing table must be associated with the same VPC that the virtual private gateway is attached to.
VpcIdstringThe ID of the VPC.
regionstringAWS region (default: us-east-1)
CarrierGatewayIdstring[IPv4 traffic only] The ID of a carrier gateway.
ClientTokenstringUnique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensuring idempotency.
CoreNetworkArnstringThe Amazon Resource Name (ARN) of the core network.
DestinationCidrBlockstringThe IPv4 CIDR range for the route. The value you specify must match the CIDR for the route exactly.
DestinationIpv6CidrBlockstringThe IPv6 CIDR range for the route. The value you specify must match the CIDR for the route exactly.
DestinationPrefixListIdstringThe ID of the prefix list for the route.
DryRunbooleanChecks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.
EgressOnlyInternetGatewayIdstring[IPv6 traffic only] The ID of an egress-only internet gateway.
FilterarrayThe filters. association.gateway-id - The ID of the gateway involved in the association. association.route-table-association-id - The ID of an association ID for the route table. association.route-table-id - The ID of the route table involved in the association. association.subnet-id - The ID of the subnet involved in the association. association.main - Indicates whether the route table is the main route table for the VPC (true | false). Route tables that do not have an association ID are not returned in the response. owner-id - The ID of the Amazon Web Services account that owns the route table. route-table-id - The ID of the route table. route.destination-cidr-block - The IPv4 CIDR range specified in a route in the table. route.destination-ipv6-cidr-block - The IPv6 CIDR range specified in a route in the route table. route.destination-prefix-list-id - The ID (prefix) of the Amazon Web Services service specified in a route in the table. route.egress-only-internet-gateway-id - The ID of an egress-only Internet gateway specified in a route in the route table. route.gateway-id - The ID of a gateway specified in a route in the table. route.instance-id - The ID of an instance specified in a route in the table. route.nat-gateway-id - The ID of a NAT gateway. route.transit-gateway-id - The ID of a transit gateway. route.origin - Describes how the route was created. CreateRouteTable indicates that the route was automatically created when the route table was created; CreateRoute indicates that the route was manually added to the route table; EnableVgwRoutePropagation indicates that the route was propagated by route propagation. route.state - The state of a route in the route table (active | blackhole). The blackhole state indicates that the route's target isn't available (for example, the specified gateway isn't attached to the VPC, the specified NAT instance has been terminated, and so on). route.vpc-peering-connection-id - The ID of a VPC peering connection specified in a route in the table. tag - The key/value combination of a tag assigned to the resource. Use the tag key in the filter name and the tag value as the filter value. For example, to find all resources that have a tag with the key Owner and the value TeamA, specify tag:Owner for the filter name and TeamA for the filter value. tag-key - The key of a tag assigned to the resource. Use this filter to find all resources assigned a tag with a specific key, regardless of the tag value. vpc-id - The ID of the VPC for the route table.
GatewayIdstringThe ID of an internet gateway or virtual private gateway.
InstanceIdstringThe ID of a NAT instance in your VPC.
LocalGatewayIdstringThe ID of the local gateway.
LocalTargetbooleanSpecifies whether to reset the local route to its default target (local).
MaxResultsintegerThe maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. For more information, see Pagination.
NatGatewayIdstring[IPv4 traffic only] The ID of a NAT gateway.
NetworkInterfaceIdstringThe ID of a network interface.
NextTokenstringThe token returned from a previous paginated request. Pagination continues from the end of the items returned by the previous request.
OdbNetworkArnstringThe Amazon Resource Name (ARN) of the ODB network.
PublicIpv4PoolstringThe ID of a public IPv4 pool. A public IPv4 pool is a pool of IPv4 addresses that you've brought to Amazon Web Services with BYOIP.
RouteTableIdarrayThe IDs of the route tables.
SubnetIdstringThe ID of the subnet.
TagSpecificationarrayThe tags to assign to the route table.
TransitGatewayIdstringThe ID of a transit gateway.
VpcEndpointIdstringThe ID of a VPC endpoint. Supported for Gateway Load Balancer endpoints only.
VpcPeeringConnectionIdstringThe ID of a VPC peering connection.

SELECT examples

Describes your route tables. The default is to describe all your route tables. Alternatively, you can specify specific route table IDs or filter the results to include only the route tables that match specific criteria. Each subnet in your VPC must be associated with a route table. If a subnet is not explicitly associated with any route table, it is implicitly associated with the main route table. This command does not return the subnet ID for implicit associations. For more information, see Route tables in the Amazon VPC User Guide.

SELECT
associations,
owner_id,
propagating_vgws,
route_table_id,
routes,
tags,
vpc_id
FROM aws.ec2.route_tables
WHERE region = '{{ region }}' -- required
AND NextToken = '{{ NextToken }}'
AND MaxResults = '{{ MaxResults }}'
AND DryRun = '{{ DryRun }}'
AND RouteTableId = '{{ RouteTableId }}'
AND Filter = '{{ Filter }}'
;

INSERT examples

Creates a route in a route table within a VPC. You must specify either a destination CIDR block or a prefix list ID. You must also specify exactly one of the resources from the parameter list. When determining how to route traffic, we use the route with the most specific match. For example, traffic is destined for the IPv4 address 192.0.2.3, and the route table includes the following two IPv4 routes: 192.0.2.0/24 (goes to some target A) 192.0.2.0/28 (goes to some target B) Both routes apply to the traffic destined for 192.0.2.3. However, the second route in the list covers a smaller number of IP addresses and is therefore more specific, so we use that route to determine where to target the traffic. For more information about route tables, see Route tables in the Amazon VPC User Guide.

INSERT INTO aws.ec2.route_tables (
RouteTableId,
region,
DestinationPrefixListId,
VpcEndpointId,
TransitGatewayId,
LocalGatewayId,
CarrierGatewayId,
CoreNetworkArn,
OdbNetworkArn,
DryRun,
DestinationCidrBlock,
GatewayId,
DestinationIpv6CidrBlock,
EgressOnlyInternetGatewayId,
InstanceId,
NetworkInterfaceId,
VpcPeeringConnectionId,
NatGatewayId
)
SELECT
'{{ RouteTableId }}',
'{{ region }}',
'{{ DestinationPrefixListId }}',
'{{ VpcEndpointId }}',
'{{ TransitGatewayId }}',
'{{ LocalGatewayId }}',
'{{ CarrierGatewayId }}',
'{{ CoreNetworkArn }}',
'{{ OdbNetworkArn }}',
'{{ DryRun }}',
'{{ DestinationCidrBlock }}',
'{{ GatewayId }}',
'{{ DestinationIpv6CidrBlock }}',
'{{ EgressOnlyInternetGatewayId }}',
'{{ InstanceId }}',
'{{ NetworkInterfaceId }}',
'{{ VpcPeeringConnectionId }}',
'{{ NatGatewayId }}'
RETURNING
return
;

UPDATE examples

Associates a subnet in your VPC or an internet gateway or virtual private gateway attached to your VPC with a route table in your VPC. This association causes traffic from the subnet or gateway to be routed according to the routes in the route table. The action returns an association ID, which you need in order to disassociate the route table later. A route table can be associated with multiple subnets. For more information, see Route tables in the Amazon VPC User Guide.

UPDATE aws.ec2.route_tables
SET
-- No updatable properties
WHERE
RouteTableId = '{{ RouteTableId }}' --required
AND region = '{{ region }}' --required
AND GatewayId = '{{ GatewayId}}'
AND PublicIpv4Pool = '{{ PublicIpv4Pool}}'
AND DryRun = {{ DryRun}}
AND SubnetId = '{{ SubnetId}}'
RETURNING
association_id,
association_state;

REPLACE examples

Changes the route table associated with a given subnet, internet gateway, or virtual private gateway in a VPC. After the operation completes, the subnet or gateway uses the routes in the new route table. For more information about route tables, see Route tables in the Amazon VPC User Guide. You can also use this operation to change which table is the main route table in the VPC. Specify the main route table's association ID and the route table ID of the new main route table.

REPLACE aws.ec2.route_tables
SET
-- No updatable properties
WHERE
AssociationId = '{{ AssociationId }}' --required
AND RouteTableId = '{{ RouteTableId }}' --required
AND region = '{{ region }}' --required
AND DryRun = {{ DryRun}}
RETURNING
association_state,
new_association_id;

DELETE examples

Deletes the specified route table. You must disassociate the route table from any subnets before you can delete it. You can't delete the main route table.

DELETE FROM aws.ec2.route_tables
WHERE RouteTableId = '{{ RouteTableId }}' --required
AND region = '{{ region }}' --required
AND DryRun = '{{ DryRun }}'
;

Lifecycle Methods

Deletes the specified route from the specified route table.

EXEC aws.ec2.route_tables.delete_route
@RouteTableId='{{ RouteTableId }}' --required,
@region='{{ region }}' --required,
@DestinationPrefixListId='{{ DestinationPrefixListId }}',
@DryRun={{ DryRun }},
@DestinationCidrBlock='{{ DestinationCidrBlock }}',
@DestinationIpv6CidrBlock='{{ DestinationIpv6CidrBlock }}'
;