create_route
async
¶
create_route(
*,
config_overrides: Optional[AsyncEC2ClientConfig] = None,
destination_prefix_list_id: Optional[PrefixListResourceId] = None,
vpc_endpoint_id: Optional[VpcEndpointId] = None,
transit_gateway_id: Optional[TransitGatewayId] = None,
local_gateway_id: Optional[LocalGatewayId] = None,
carrier_gateway_id: Optional[CarrierGatewayId] = None,
core_network_arn: Optional[CoreNetworkArn] = None,
odb_network_arn: Optional[OdbNetworkArn] = None,
dry_run: Optional[Boolean] = None,
route_table_id: Optional[RouteTableId] = None,
destination_cidr_block: Optional[String] = None,
gateway_id: Optional[RouteGatewayId] = None,
destination_ipv6_cidr_block: Optional[String] = None,
egress_only_internet_gateway_id: Optional[EgressOnlyInternetGatewayId] = None,
instance_id: Optional[InstanceId] = None,
network_interface_id: Optional[NetworkInterfaceId] = None,
vpc_peering_connection_id: Optional[VpcPeeringConnectionId] = None,
nat_gateway_id: Optional[NatGatewayId] = None,
) -> CreateRouteResult
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.
Parameters:
-
destination_prefix_list_id(Optional[PrefixListResourceId], default:None) –The ID of a prefix list used for the destination match.
-
vpc_endpoint_id(Optional[VpcEndpointId], default:None) –The ID of a VPC endpoint. Supported for Gateway Load Balancer endpoints only.
-
transit_gateway_id(Optional[TransitGatewayId], default:None) –The ID of a transit gateway.
-
local_gateway_id(Optional[LocalGatewayId], default:None) –The ID of the local gateway.
-
carrier_gateway_id(Optional[CarrierGatewayId], default:None) –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.
-
core_network_arn(Optional[CoreNetworkArn], default:None) –The Amazon Resource Name (ARN) of the core network.
-
odb_network_arn(Optional[OdbNetworkArn], default:None) –The Amazon Resource Name (ARN) of the ODB network.
-
dry_run(Optional[Boolean], default:None) –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 isUnauthorizedOperation. -
route_table_id(Optional[RouteTableId], default:None) –The ID of the route table for the route.
-
destination_cidr_block(Optional[String], default:None) –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 to100.68.0.0/18. -
gateway_id(Optional[RouteGatewayId], default:None) –The ID of an internet gateway or virtual private gateway attached to your VPC.
-
destination_ipv6_cidr_block(Optional[String], default:None) –The IPv6 CIDR block used for the destination match. Routing decisions are based on the most specific match.
-
egress_only_internet_gateway_id(Optional[EgressOnlyInternetGatewayId], default:None) –[IPv6 traffic only] The ID of an egress-only internet gateway.
-
instance_id(Optional[InstanceId], default:None) –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.
-
network_interface_id(Optional[NetworkInterfaceId], default:None) –The ID of a network interface.
-
vpc_peering_connection_id(Optional[VpcPeeringConnectionId], default:None) –The ID of a VPC peering connection.
-
nat_gateway_id(Optional[NatGatewayId], default:None) –[IPv4 traffic only] The ID of a NAT gateway.
Raises:
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To create a route This example creates a route for the specified route table. The route matches all traffic (0.0.0.0/0) and routes it to the specified Internet gateway.
>>> await client.create_route(route_table_id='rtb-22574640', destination_cidr_block='0.0.0.0/0', gateway_id='igw-c0a643a9')
Source code in docs_src/capo_ec2/_services/async_ec2.py
11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 | |