Creates a virtual private cloud (VPC).

Descriptions

When you call this operation, take note of the following 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 CIDR block is 172.16.0.0/12.
  • After you create a VPC, you cannot modify its CIDR block.
  • Each VPC can use at most 60,000 private IP addresses. The quota cannot be increased.
  • After you create a VPC, a vRouter and a route table are automatically created.
  • At most three user CIDR blocks can be added to a VPC. If a user CIDR block includes another user 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

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

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 where the VPC is deployed. You can call the DescribeRegions operation to query the most recent region list.

CidrBlock String No 172.16.0.0/12

The CIDR block of the VPC. You can use one of the following CIDR blocks or their subnets as the CIDR block of your VPC:

  • 172.16.0.0/12 (default).
  • 10.0.0.0/8.
  • 192.168.0.0/16.
Ipv6CidrBlock String No 2408:XXXX:0:6a::/56

The IPv6 CIDR block of the VPC.

EnableIpv6 Boolean No false

Specifies whether to enable the IPv6 CIDR block. Valid values:

  • false (default) disabled
  • true: enabled
VpcName String No abc

The name of the VPC.

The name must be 2 to 128 characters in length, and can contain digits, periods (.), underscores (_), and hyphens (-). It must start with a letter and cannot start with http:// or https://.

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 and cannot start with http:// or https://.

ResourceGroupId String No rg-acfmxazb4ph6aiy****

The ID of the resource group.

DryRun Boolean No false

Specifies whether to precheck this request. Valid values:

  • true: sends a check request without creating a VPC. The system prechecks the required parameters, request format, and service limits. If the request fails the precheck, the corresponding error code is returned. If the request passes the precheck, the DryRunOperation error code is returned.
  • false: sends the request. This is the default value. If the request passes the precheck, a 2XX HTTP status code is returned and a VPC is created.
UserCidr String No 192.16.0.0/12

The user CIDR block. Separate multiple CIDR blocks with commas (,). At most 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 make sure that it is unique among different requests. The ClientToken value must contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How can I ensure idempotence?

Ipv6Isp String No BGP

The Internet service provider (ISP) for IPv6 addresses of the VPC. Valid values:

  • BGP(default): Alibaba Cloud BGP IPv6
  • ChinaMobile: China Mobile (single line)
  • ChinaUnicom: China Unicom (single line)
  • ChinaTelecom: China Telecom (single line)
Note If your Alibaba Cloud account is allowed to activate single-ISP bandwidth, you can set the parameter to ChinaTelecom, ChinaUnicom, and ChinaMobile.

Response parameters

Parameter Type Example Description
VpcId String vpc-bp15zckdt37pq72zv****

The ID of the created VPC.

VRouterId String vrt-bp1lhl0taikrteen8****

The ID of the vRouter that is automatically created by the system after the VPC is created.

RouteTableId String vtb-bp145q7glnuzdv****

The ID of the route table that is 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.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateVpc
&RegionId=cn-hangzhou
&<Common request parameters>

Sample success responses

XML format

<CreateVpcResponse>
  <VRouterId>vrt-bp1lhl0taikrteen8****</VRouterId>
  <RouteTableId>vtb-bp145q7glnuzdv****</RouteTableId>
  <ResourceGroupId>rg-acfmxazb4ph6aiy****</ResourceGroupId>
  <VpcId>vpc-bp15zckdt37pq72zv****</VpcId>
  <RequestId>0ED8D006-F706-4D23-88ED-E11ED28DCAC0</RequestId>
</CreateVpcResponse>

JSON format

{
    "CreateVpcResponse": {
        "VRouterId": "vrt-bp1lhl0taikrteen8****",
        "RouteTableId": "vtb-bp145q7glnuzdv****",
        "ResourceGroupId": "rg-acfmxazb4ph6aiy****",
        "VpcId": "vpc-bp15zckdt37pq72zv****",
        "RequestId": "0ED8D006-F706-4D23-88ED-E11ED28DCAC0"
    }
}

Error codes

HttpCode 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 the region ID is valid.
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 you cannot create a vSwitch 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. Enter a valid VPC name and try again.
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 unauthorized to perform this operation on the specified resource. You can apply for the permissions and try again.
400 QuotaExceeded.Vpc VPC quota exceeded. The error message returned because the number of VPCs under the Apsara Stack tenant account has reached the upper limit. You can submit a ticket to request a quota increase.
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 UserCidr value has reached the upper limit.
400 InvalidUserCidr.Malformed Specified UserCidr overlapping in of 100.64.0.0/10. The error message returned because the UserCidr value 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.
400 InvalidResourceGroupId The specified ResourceGroupId does not exist. The error message returned because the specified resource group ID is invalid.
400 OperationUnsupported.ResourceGroupId ResourceGroup is not supported in this region. The error message returned because the resource group feature is not enabled.

For a list of error codes, visit the API Error Center.