All Products
Search
Document Center

Virtual Private Cloud:CreateRouteEntries

Last Updated:Dec 01, 2023

Adds custom route entries to the route table of a vRouter in a virtual private cloud (VPC).

Operation Description

References

  • CreateRouteEntries is an asynchronous operation. After a request is sent, the system returns a request ID and runs the task in the background. You can call the DescribeRouteEntryList operation to query the status of the task.

    • If the route entry is in the Creating state, the route entry is being created.
    • If the route entry is in the Created state, the route entry is created.
  • You cannot repeatedly call the CreateRouteEntries operation to create the same route entry within the specified period of time.

When you call this operation to add custom route entries to the route table of a vRouter, take note of the following items:

  • A route table can contain up to 200 custom route entries.
  • The destination CIDR block (DstCidrBlock) of a custom route entry cannot be the same as or overlap with the CIDR block of a vSwitch in the VPC.
  • The destination CIDR block (DstCidrBlock) of a custom route entry cannot be 100.64.0.0/10 or its subnets.
  • The destination CIDR blocks (DstCidrBlock) of route entries in the same route table must be unique.
  • If you do not include the mask length when you specify the destination CIDR block (DstCidrBlock), the destination CIDR block is considered a host IP address whose mask length is 32 bits.
  • Multiple custom route entries can point to the same next hop (NextHop).
  • The next hop (NextHop) of a custom route entry must belong to the same VPC as the route table.

debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

debugging

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
vpc:CreateRouteEntriesWrite
  • RouteEntry
    acs:vpc:{#regionId}:{#accountId}:routetable/{#RouteTableId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID of the route table.

You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
RouteEntriesobject []Yes

The route entries.

DstCidrBlockstringYes

The destination CIDR block of the custom route entry. Both IPv4 and IPv6 CIDR blocks are supported. You can specify up to 50 destination CIDR blocks. Make sure that the destination CIDR block meets the following requirements:

  • The destination CIDR block is not 100.64.0.0/10 or a subset of 100.64.0.0/10.
  • The destination CIDR block of the custom route entry is different from the destination CIDR blocks of other route entries in the same route table.
192.168.0.0/24
RouteTableIdstringYes

The ID of the route table to which you want to add a custom route entry. You can specify up to 50 route table IDs.

vtb-bp145q7glnuzd****
IpVersionintegerNo

The IP version. You can specify up to 50 IP versions. Valid values:

  • 4: IPv4
  • 6: IPv6
IPv4
NextHopstringYes

The next hop ID of the custom route entry. You can specify up to 50 next hop IDs.

i-j6c2fp57q8rr4jlu****
NextHopTypestringYes

The type of next hop. You can specify up to 50 next hop types. Valid values:

  • Instance (default): an Elastic Compute Service (ECS) instance
  • HaVip: a high-availability virtual IP address (HAVIP).
  • RouterInterface: a router interface.
  • NetworkInterface: an elastic network interface (ENI).
  • VpnGateway: a VPN gateway.
  • IPv6Gateway: an IPv6 gateway.
  • NatGateway: a NAT gateway.
  • Attachment: a transit router.
  • VpcPeer: a VPC peering connection.
RouterInterface
NamestringNo

The name of the custom route entry 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 http:// or https://.

test
DescriptionstringNo

The description of the custom route entry. You can specify up to 50 descriptions.

The description must be 1 to 256 characters in length and cannot start with http:// or https://.

test

Response parameters

ParameterTypeDescriptionExample
object

The number of completed tasks.

SuccessCountinteger

The number of custom route entries that were successfully added.

2
FailedCountinteger

The number of custom route entries that failed to be added.

2
RequestIdstring

The request ID.

0ED8D006-F706-4D23-88ED-E11ED28DCAC0
FailedRouteEntriesobject []

The details about the custom route entry that failed to be added.

DstCidrBlockstring

The destination CIDR block of the custom route entry that failed to be added.

192.168.0.0/24
NextHopstring

The ID of the next hop of the custom route entry that failed to be added.

i-j6c2fp57q8rr4jlu****
FailedCodestring

The error code.

VPC_ROUTE_ENTRY_CIDR_BLOCK_DUPLICATE
FailedMessagestring

The error message.

Specified CIDR block is already exists, entry.cidrBlock=xxxx
RouteEntryIdsarray

The information about the ID of the custom route entry that was successfully added.

string

The ID of the custom route entry that was successfully added.

rte-sn6vjkioxte1gz83z****

Examples

Sample success responses

JSONformat

{
  "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 codeError codeError messageDescription
400DryRunOperationRequest validation has been passed with DryRun flag set.The request passed the dry run.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-08-07API Description Update,The error codes of the API operation change.see changesets
Change itemChange content
API DescriptionAPI Description Update
Error CodesThe error codes of the API operation change.
    delete Error Codes: 400
2023-03-30The error codes of the API operation change.see changesets
Change itemChange content
Error CodesThe error codes of the API operation change.
    delete Error Codes: 400