create_route
¶
create_route(
*,
config_overrides: Optional[EC2ClientConfig] = 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.
>>> 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/ec2.py
11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 | |