All Products
Search
Document Center

Virtual Private Cloud:CreateRouteEntries

Last Updated:Dec 20, 2024

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.

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:CreateRouteEntriescreate
*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
RouteEntriesarray<object>Yes

The routes.

objectYes
DstCidrBlockstringYes

The destination CIDR block of the custom route. IPv4 CIDR blocks, IPv6 CIDR blocks, and prefix lists are supported. You can enter up to 50 destination CIDR blocks. Make sure that the following requirements are met:

  • The destination CIDR block cannot point to 100.64.0.0/10 or belong to 100.64.0.0/10.
  • The destination CIDR block of each route in the route table is unique.
192.168.0.0/24
RouteTableIdstringYes

The ID of the route table to which you want to add custom route s. You can specify at most 50 route table IDs.

vtb-bp145q7glnuzd****
IpVersionintegerNo

The IP version. Valid values: You can specify at most 50 IP versions. Valid values:

  • 4: IPv4
  • 6: IPv6
IPv4
NextHopstringYes

The ID of the next hop for the custom route. You can specify at most 50 instance IDs.

i-j6c2fp57q8rr4jlu****
NextHopTypestringYes

The type of next hop. You can specify at most 50 next hop types. Valid values:

  • Instance: Elastic Compute Service (ECS) instance. This is the default value.
  • HaVip: high-availability virtual IP address (HAVIP).
  • RouterInterface: router interface.
  • NetworkInterface: elastic network interface (ENI).
  • VpnGateway: VPN gateway.
  • IPv6Gateway: IPv6 gateway.
  • NatGateway: NAT gateway.
  • Attachment: transit router.
  • VpcPeer: VPC peering connection.
  • Ipv4Gateway: IPv4 gateway.
  • GatewayEndpoint: gateway endpoint.
  • CenBasic: CEN does not support transfer routers.
  • Ecr: Express Connect Router (ECR).
RouterInterface
NamestringNo

The name of the custom route that you want to add. You can specify at most 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. You can specify at most 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
FailedRouteEntriesarray<object>

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

FailedRouteEntriesobject
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.

RouteEntryIdsstring

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 code has changedView Change Details
2023-03-30The Error code has changedView Change Details