Adds custom routes in a batch to the route table of a VPC router.
Operation description
- CreateRouteEntries is an asynchronous operation. After you send a request, the system returns a request ID, but the operation is still being performed in the background. You can call DescribeRouteEntryList to query the status of a route:
If a route is in the Creating state, the route is being created.
If a route is in the Created state, the route is created.
CreateRouteEntries does not support concurrent batch operations to add custom routes to the same VPC.
Note the following when you add custom routes to the route table of a VPC router:
-
A route table can contain a maximum of 200 custom routes.
-
The destination CIDR block (DstCidrBlock) of a custom route cannot be the same as, overlap with, or be a subset of the CIDR block of a vSwitch in the VPC.
-
The destination CIDR block (DstCidrBlock) of a custom route cannot be 100.64.0.0/10 or a subset of 100.64.0.0/10.
-
The destination CIDR blocks (DstCidrBlock) of routes in the same route table cannot be the same.
-
An IP address specified as the destination CIDR block (DstCidrBlock) is processed with a 32-bit subnet mask.
-
Multiple custom routes can point to the same next hop (NextHop).
-
The next hop (NextHop) of a custom route must be in the same VPC as the route table.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
vpc:CreateRouteEntries |
create |
*RouteEntry
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The ID of the region where the route table is located. You can call the DescribeRegions operation to query the most recent region list. |
cn-hangzhou |
| RegionId |
string |
Yes |
The ID of the region where the route table is located. You can call the DescribeRegions operation to query the most recent region list. |
cn-hangzhou |
| RouteEntries |
array<object> |
Yes |
The list of route information. |
|
|
object |
No |
The list of route information. |
||
| DstCidrBlock |
string |
Yes |
The destination CIDR block of the custom route. Both IPv4 and IPv6 CIDR blocks are supported. You can specify up to 50 destination CIDR blocks. The destination CIDR blocks must meet the following requirements:
|
192.168.0.0/24 |
| RouteTableId |
string |
Yes |
The ID of the route table to which you want to add custom routes. You can specify up to 50 route table IDs. |
vtb-bp145q7glnuzd**** |
| IpVersion |
integer |
No |
The IP protocol version. You can specify up to 50 IP protocol versions. Valid values:
|
4 |
| NextHop |
string |
Yes |
The ID of the next hop instance for the custom route. You can specify up to 50 instance IDs. Note
If you set NextHopType to Ecr, call the DescribeExpressConnectRouterAssociation operation to obtain the AssociationId and use it as the next hop ID. |
i-j6c2fp57q8rr4jlu**** |
| NextHopType |
string |
Yes |
The type of the next hop for the custom route. You can specify up to 50 next hop types. Valid values:
|
RouterInterface |
| Name |
string |
No |
The name of the custom route that you want to add. You can specify up to 50 names. The name must be 1 to 128 characters in length and cannot start with |
test |
| Description |
string |
No |
The description of the custom route. You can specify up to 50 descriptions. The description must be 1 to 256 characters in length and cannot start with |
test |
| DryRun |
boolean |
No |
Specifies whether to perform a dry run. Valid values: true: Sends a request to check whether the request is valid. The system checks whether your AccessKey is valid, whether the RAM user is authorized, and whether the required parameters are specified. If the request fails the check, an error message is returned. If the request passes the check, the false (default): Sends a normal request. After the request passes the check, a 2xx HTTP status code is returned and the routes are created. |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The number of successful tasks. |
||
| SuccessCount |
integer |
The number of custom routes that are successfully added. |
2 |
| FailedCount |
integer |
The number of custom routes that failed to be added. |
2 |
| RequestId |
string |
The request ID. |
0ED8D006-F706-4D23-88ED-E11ED28DCAC0 |
| FailedRouteEntries |
array<object> |
The details about the custom routes that failed to be added. |
|
|
object |
The details about the custom routes that failed to be added. |
||
| DstCidrBlock |
string |
The destination CIDR block of the custom route that failed to be added. |
192.168.0.0/24 |
| NextHop |
string |
The ID of the next hop of the custom route that failed to be added. |
i-j6c2fp57q8rr4jlu**** |
| FailedCode |
string |
The error code. |
VPC_ROUTE_ENTRY_CIDR_BLOCK_DUPLICATE |
| FailedMessage |
string |
The error message. |
Specified CIDR block is already exists, entry.cidrBlock=xxxx |
| RouteEntryIds |
array |
The information about the IDs of the custom routes that are successfully added. |
|
|
string |
The ID of the custom route that is successfully added. |
rte-sn6vjkioxte1gz83z**** |
Examples
Success response
JSON format
{
"SuccessCount": 2,
"FailedCount": 2,
"RequestId": "0ED8D006-F706-4D23-88ED-E11ED28DCAC0",
"FailedRouteEntries": [
{
"DstCidrBlock": "192.168.0.0/24",
"NextHop": "i-j6c2fp57q8rr4jlu****",
"FailedCode": "VPC_ROUTE_ENTRY_CIDR_BLOCK_DUPLICATE",
"FailedMessage": "Specified CIDR block is already exists, entry.cidrBlock=xxxx"
}
],
"RouteEntryIds": [
"rte-sn6vjkioxte1gz83z****"
]
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | DryRunOperation | Request validation has been passed with DryRun flag set. | The request passed the dry run. |
| 400 | InvalidCIDRBlock.Duplicate | Specified CIDR block is already exists. | |
| 400 | MissingParam.RouteTableId | The parameter RouteTableId is missing. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.