route_tables
Creates, updates, deletes, gets or lists a route_tables resource.
Overview
| Name | route_tables |
| Type | Resource |
| Id | aws.ec2.route_tables |
Fields
The following fields are returned by SELECT queries:
- describe_route_tables
| Name | Datatype | Description |
|---|---|---|
associations | string | The associations between the route table and your subnets or gateways. |
owner_id | string | The ID of the Amazon Web Services account that owns the route table. |
propagating_vgws | string | Any virtual private gateway (VGW) propagating routes. |
route_table_id | string | The ID of the route table. |
routes | string | The routes in the route table. |
tags | string | Any tags assigned to the route table. |
vpc_id | string | The ID of the VPC. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
describe_route_tables | select | region | NextToken, MaxResults, DryRun, RouteTableId, Filter | 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. |
create_route | insert | RouteTableId, region | DestinationPrefixListId, VpcEndpointId, TransitGatewayId, LocalGatewayId, CarrierGatewayId, CoreNetworkArn, OdbNetworkArn, DryRun, DestinationCidrBlock, GatewayId, DestinationIpv6CidrBlock, EgressOnlyInternetGatewayId, InstanceId, NetworkInterfaceId, VpcPeeringConnectionId, NatGatewayId | 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. |
create_route_table | insert | VpcId, region | TagSpecification, ClientToken, DryRun | Creates 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_table | update | RouteTableId, region | GatewayId, PublicIpv4Pool, DryRun, SubnetId | 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. |
disassociate_route_table | update | AssociationId, region | DryRun | Disassociates 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_association | replace | AssociationId, RouteTableId, region | DryRun | 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_route | replace | RouteTableId, region | DestinationPrefixListId, VpcEndpointId, LocalTarget, TransitGatewayId, LocalGatewayId, CarrierGatewayId, CoreNetworkArn, OdbNetworkArn, DryRun, DestinationCidrBlock, GatewayId, DestinationIpv6CidrBlock, EgressOnlyInternetGatewayId, InstanceId, NetworkInterfaceId, VpcPeeringConnectionId, NatGatewayId | Replaces 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_table | delete | RouteTableId, region | DryRun | 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_route | exec | RouteTableId, region | DestinationPrefixListId, DryRun, DestinationCidrBlock, DestinationIpv6CidrBlock | Deletes the specified route from the specified route table. |
disable_vgw_route_propagation | exec | GatewayId, RouteTableId, region | DryRun | Disables a virtual private gateway (VGW) from propagating routes to a specified route table of a VPC. |
enable_vgw_route_propagation | exec | GatewayId, RouteTableId, region | DryRun | Enables 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.
| Name | Datatype | Description |
|---|---|---|
AssociationId | string | The association ID. |
GatewayId | string | The 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. |
RouteTableId | string | The ID of the route table. The routing table must be associated with the same VPC that the virtual private gateway is attached to. |
VpcId | string | The ID of the VPC. |
region | string | AWS region (default: us-east-1) |
CarrierGatewayId | string | [IPv4 traffic only] The ID of a carrier gateway. |
ClientToken | string | Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensuring idempotency. |
CoreNetworkArn | string | The Amazon Resource Name (ARN) of the core network. |
DestinationCidrBlock | string | The IPv4 CIDR range for the route. The value you specify must match the CIDR for the route exactly. |
DestinationIpv6CidrBlock | string | The IPv6 CIDR range for the route. The value you specify must match the CIDR for the route exactly. |
DestinationPrefixListId | string | The ID of the prefix list for the route. |
DryRun | boolean | Checks 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. |
EgressOnlyInternetGatewayId | string | [IPv6 traffic only] The ID of an egress-only internet gateway. |
Filter | array | The 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. |
GatewayId | string | The ID of an internet gateway or virtual private gateway. |
InstanceId | string | The ID of a NAT instance in your VPC. |
LocalGatewayId | string | The ID of the local gateway. |
LocalTarget | boolean | Specifies whether to reset the local route to its default target (local). |
MaxResults | integer | The 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. |
NatGatewayId | string | [IPv4 traffic only] The ID of a NAT gateway. |
NetworkInterfaceId | string | The ID of a network interface. |
NextToken | string | The token returned from a previous paginated request. Pagination continues from the end of the items returned by the previous request. |
OdbNetworkArn | string | The Amazon Resource Name (ARN) of the ODB network. |
PublicIpv4Pool | string | The 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. |
RouteTableId | array | The IDs of the route tables. |
SubnetId | string | The ID of the subnet. |
TagSpecification | array | The tags to assign to the route table. |
TransitGatewayId | string | The ID of a transit gateway. |
VpcEndpointId | string | The ID of a VPC endpoint. Supported for Gateway Load Balancer endpoints only. |
VpcPeeringConnectionId | string | The ID of a VPC peering connection. |
SELECT examples
- describe_route_tables
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
- create_route
- create_route_table
- Manifest
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
;
Creates 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.
INSERT INTO aws.ec2.route_tables (
VpcId,
region,
TagSpecification,
ClientToken,
DryRun
)
SELECT
'{{ VpcId }}',
'{{ region }}',
'{{ TagSpecification }}',
'{{ ClientToken }}',
'{{ DryRun }}'
RETURNING
associations,
owner_id,
propagating_vgws,
route_table_id,
routes,
tags,
vpc_id
;
# Description fields are for documentation purposes
- name: route_tables
props:
- name: RouteTableId
value: "{{ RouteTableId }}"
description: Required parameter for the route_tables resource.
- name: region
value: "{{ region }}"
description: Required parameter for the route_tables resource.
- name: VpcId
value: "{{ VpcId }}"
description: Required parameter for the route_tables resource.
- name: DestinationPrefixListId
value: "{{ DestinationPrefixListId }}"
description: The ID of a prefix list used for the destination match.
description: The ID of a prefix list used for the destination match.
- name: VpcEndpointId
value: "{{ VpcEndpointId }}"
description: The ID of a VPC endpoint. Supported for Gateway Load Balancer endpoints only.
description: The ID of a VPC endpoint. Supported for Gateway Load Balancer endpoints only.
- name: TransitGatewayId
value: "{{ TransitGatewayId }}"
description: The ID of a transit gateway.
description: The ID of a transit gateway.
- name: LocalGatewayId
value: "{{ LocalGatewayId }}"
description: The ID of the local gateway.
description: The ID of the local gateway.
- name: CarrierGatewayId
value: "{{ CarrierGatewayId }}"
description: The ID of the carrier gateway. You can only use this option when the VPC contains a subnet which is associated with a Wavelength Zone.
description: The ID of the carrier gateway. You can only use this option when the VPC contains a subnet which is associated with a Wavelength Zone.
- name: CoreNetworkArn
value: "{{ CoreNetworkArn }}"
description: The Amazon Resource Name (ARN) of the core network.
description: The Amazon Resource Name (ARN) of the core network.
- name: OdbNetworkArn
value: "{{ OdbNetworkArn }}"
description: The Amazon Resource Name (ARN) of the ODB network.
description: The Amazon Resource Name (ARN) of the ODB network.
- name: DryRun
value: {{ DryRun }}
description: Checks 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.
description: Checks 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.
- name: DestinationCidrBlock
value: "{{ DestinationCidrBlock }}"
description: The IPv4 CIDR address block used for the destination match. Routing decisions are based on the most specific match. We modify the specified CIDR block to its canonical form; for example, if you specify 100.68.0.18/18, we modify it to 100.68.0.0/18.
description: The IPv4 CIDR address block used for the destination match. Routing decisions are based on the most specific match. We modify the specified CIDR block to its canonical form; for example, if you specify 100.68.0.18/18, we modify it to 100.68.0.0/18.
- name: GatewayId
value: "{{ GatewayId }}"
description: The ID of an internet gateway or virtual private gateway attached to your VPC.
description: The ID of an internet gateway or virtual private gateway attached to your VPC.
- name: DestinationIpv6CidrBlock
value: "{{ DestinationIpv6CidrBlock }}"
description: The IPv6 CIDR block used for the destination match. Routing decisions are based on the most specific match.
description: The IPv6 CIDR block used for the destination match. Routing decisions are based on the most specific match.
- name: EgressOnlyInternetGatewayId
value: "{{ EgressOnlyInternetGatewayId }}"
description: [IPv6 traffic only] The ID of an egress-only internet gateway.
description: [IPv6 traffic only] The ID of an egress-only internet gateway.
- name: InstanceId
value: "{{ InstanceId }}"
description: The ID of a NAT instance in your VPC. The operation fails if you specify an instance ID unless exactly one network interface is attached.
description: The ID of a NAT instance in your VPC. The operation fails if you specify an instance ID unless exactly one network interface is attached.
- name: NetworkInterfaceId
value: "{{ NetworkInterfaceId }}"
description: The ID of a network interface.
description: The ID of a network interface.
- name: VpcPeeringConnectionId
value: "{{ VpcPeeringConnectionId }}"
description: The ID of a VPC peering connection.
description: The ID of a VPC peering connection.
- name: NatGatewayId
value: "{{ NatGatewayId }}"
description: [IPv4 traffic only] The ID of a NAT gateway.
description: [IPv4 traffic only] The ID of a NAT gateway.
- name: TagSpecification
value: "{{ TagSpecification }}"
description: The tags to assign to the route table.
description: The tags to assign to the route table.
- name: ClientToken
value: "{{ ClientToken }}"
description: Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensuring idempotency.
description: Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensuring idempotency.
UPDATE examples
- associate_route_table
- disassociate_route_table
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;
Disassociates 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.
UPDATE aws.ec2.route_tables
SET
-- No updatable properties
WHERE
AssociationId = '{{ AssociationId }}' --required
AND region = '{{ region }}' --required
AND DryRun = {{ DryRun}};
REPLACE examples
- replace_route_table_association
- replace_route
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;
Replaces 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.
REPLACE aws.ec2.route_tables
SET
-- No updatable properties
WHERE
RouteTableId = '{{ RouteTableId }}' --required
AND region = '{{ region }}' --required
AND DestinationPrefixListId = '{{ DestinationPrefixListId}}'
AND VpcEndpointId = '{{ VpcEndpointId}}'
AND LocalTarget = {{ LocalTarget}}
AND TransitGatewayId = '{{ TransitGatewayId}}'
AND LocalGatewayId = '{{ LocalGatewayId}}'
AND CarrierGatewayId = '{{ CarrierGatewayId}}'
AND CoreNetworkArn = '{{ CoreNetworkArn}}'
AND OdbNetworkArn = '{{ OdbNetworkArn}}'
AND DryRun = {{ DryRun}}
AND DestinationCidrBlock = '{{ DestinationCidrBlock}}'
AND GatewayId = '{{ GatewayId}}'
AND DestinationIpv6CidrBlock = '{{ DestinationIpv6CidrBlock}}'
AND EgressOnlyInternetGatewayId = '{{ EgressOnlyInternetGatewayId}}'
AND InstanceId = '{{ InstanceId}}'
AND NetworkInterfaceId = '{{ NetworkInterfaceId}}'
AND VpcPeeringConnectionId = '{{ VpcPeeringConnectionId}}'
AND NatGatewayId = '{{ NatGatewayId}}';
DELETE examples
- delete_route_table
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
- delete_route
- disable_vgw_route_propagation
- enable_vgw_route_propagation
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 }}'
;
Disables a virtual private gateway (VGW) from propagating routes to a specified route table of a VPC.
EXEC aws.ec2.route_tables.disable_vgw_route_propagation
@GatewayId='{{ GatewayId }}' --required,
@RouteTableId='{{ RouteTableId }}' --required,
@region='{{ region }}' --required,
@DryRun={{ DryRun }}
;
Enables a virtual private gateway (VGW) to propagate routes to the specified route table of a VPC.
EXEC aws.ec2.route_tables.enable_vgw_route_propagation
@GatewayId='{{ GatewayId }}' --required,
@RouteTableId='{{ RouteTableId }}' --required,
@region='{{ region }}' --required,
@DryRun={{ DryRun }}
;