Creates a virtual private cloud (VPC).
Description
When you call this operation, follow these rules:
- You can specify only one CIDR block for a VPC. The CIDR block must be 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, or their subnets, and the subnet mask must be 8 to 24 bits in length. The default value is 172.16.0.0/12.
- When you create a VPC, its CIDR block cannot be modified.
- Each VPC can use 60,000 private IP addresses for the Alibaba Cloud services. The quota cannot be increased.
- After you create a VPC, a VRouter and a route table are automatically created.
- A maximum of three client-side CIDR blocks can be added to a VPC. If a client-side CIDR block includes another client-side CIDR block, the one with the shorter subnet mask takes effect. For example, if both 10.0.0.0/8 and 10.1.0.0/16 are specified, only 10.0.0.0/8 takes effect.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | CreateVpc |
The operation that you want to perform. Set the value to CreateVpc. |
RegionId | String | Yes | cn-hangzhou |
The ID of the region to which the VPC belongs. You can call the DescribeRegions operation to query the ID of the region to which the VPC instance belongs. |
CidrBlock | String | No | 172.16.0.0/12 |
The CIDR block of the VPC. You can use the following CIDR blocks or their subnets as the CIDR blocks of your VPC:
|
Ipv6CidrBlock | String | No | 2408:4004:0:6axx::/56 |
The IPv6 CIDR block of the VPC. |
EnableIpv6 | Boolean | No | false |
Specifies whether to enable the IPv6 CIDR block. Valid values:
|
VpcName | String | No | abc |
The name of the VPC. The name must be 2 to 128 characters in length and can contain letters, digits, periods
(.), underscores (_), and hyphens (-). It must start with a letter or a Chinese character
and cannot start with |
Description | String | No | This is my first Vpc. |
The description of the VPC. The description must be 2 to 256 characters in length. It must start with a letter
or a Chinese character and cannot start with |
ResourceGroupId | String | No | rg-acfmxazb4ph6aiy**** |
The ID of the resource group to which the instance belongs. |
DryRun | Boolean | No | false |
Specifies whether to precheck this request only. Valid values:
|
UserCidr | String | No | 189.16.0.0/12 |
The user CIDR block. Separate multiple CIDR blocks with commas (,). Up to three CIDR blocks are supported. For more information, see What is a user CIDR block in CIDR block FAQ. |
ClientToken | String | No | 123e4567-e89b-12d3-a456-426655440000 |
The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must ensure that it is unique among different requests. The ClientToken can only contain ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence. |
Response parameters
Prameter | Type | Example | Description |
---|---|---|---|
VpcId | String | vpc-bp15zckdt37pq72zv**** |
The ID of the created VPC. |
VRouterId | String | vrt-bp1lhl0taikrteen8**** |
The ID of the VRouter automatically created by the system after the VPC is created. |
RouteTableId | String | vtb-bp145q7glnuzdv**** |
The ID of the route table automatically created by the system after the VPC is created. |
RequestId | String | 0ED8D006-F706-4D23-88ED-E11ED28DCAC0 |
The ID of the request. |
ResourceGroupId | String | rg-acfmxazb4ph6aiy**** |
The ID of the resource group to which the VPC instance belongs. |
Examples
Sample requests
https://vpc.aliyuncs.com/?Action=CreateVpc
&RegionId=cn-hangzhou
&<Common request parameters>
Sample success response
XML
format
<CreateVpcResponse>
<ResourceGroupId>rg-acfmxazb4ph****</ResourceGroupId>
<RequestId>8B2F5262-6B57-43F2-97C4-971425462DFE</RequestId>
<RouteTableId>vtb-bp1krxxzp0c2****</RouteTableId>
<VRouterId>vrt-bp1jcg5cmxjbl9xgc****</VRouterId>
<VpcId>vpc-bp1qpo0kug3a20qqe****</VpcId>
</CreateVpcResponse>
JSON
format
{
"ResourceGroupId": "rg-acfmxazb4ph****",
"RequestId": "8B2F5262-6B57-43F2-97C4-971425462DFE",
"RouteTableId": "vtb-bp1krxxzp0c29****",
"VRouterId": "vrt-bp1jcg5cmxjbl9xgc****",
"VpcId": "vpc-bp1qpo0kug3a20qqe****"
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
404 | InvalidRegionId.NotFound | Specified value of "regionId" is not supported. | The error message returned because the specified region ID does not exist. Check whether VPC is available in the region. |
400 | InvalidParameter | Specified CIDR block is not valid | The error message returned because the specified CIDR block is invalid. |
400 | ResourceNotAvailable | Resource you requested is not available in this region or zone. | The error message returned because VSwitches cannot be created in the current region or zone. |
400 | InvalidVpcName.Malformed | Specified VPC name is not valid. | The error message returned because the format of the VPC name is invalid. |
400 | InvalidVpcDiscription.Malformed | Specified VPC description is not valid. | The error message returned because the format of the VPC description is invalid. |
403 | Forbbiden | User not authorized to operate on the specified resource. | The error message returned because you are not authorized to perform this operation on the specified resource. |
400 | QuotaExceeded.Vpc | VPC quota exceeded. | The error message returned because the number of VPCs for the account has reached the upper limit. |
400 | ResourceNotAvailable.Vpc | Resource you requested is not available in this region or zone. | The error message returned because the resource you requested is not available in this region or zone. |
400 | InvalidParameter | Specified UserCidr invalid format. | The error message returned because the format of the user CIDR block is invalid. |
400 | InvalidParameter | Specified UserCidr Subnet mask is not valid . | The error message returned because the subnet mask of the user CIDR block is invalid. |
400 | InvalidUserCidr.Quota | Specified UserCidr number is greater than 3. | The error message returned because the quota of Usercidr has reached the limit. |
400 | InvalidUserCidr.Malformed | Specified UserCidr overlapping in of 100.64.0.0/10. | The error message returned because the UserCidr overlaps with 100.64.0.0/10. |
500 | InternalError | The request processing has failed due to some unknown error. | The error message returned because unknown errors have occurred. |
For a list of error codes, visit the API Error Center.