Creates a virtual private cloud (VPC).
Operation description
When you call this API, keep the following in mind:
Each VPC can have only one primary IPv4 CIDR block. Add secondary IPv4 CIDR blocks to extend the address space.
After the VPC is created, you can resize the IPv4 CIDR within the original range. Shrinking may fail if any allocated private IP addresses fall outside the target CIDR.
Each VPC supports up to 300,000 private addresses for cloud resources. This quota cannot be increased.
Creating a VPC automatically creates a router and a route table for that VPC.
Each VPC supports up to three user-side CIDR blocks. If one block is a superset of another, the block with the shorter mask takes effect. For example, between
10.0.0.0/16and10.0.0.0/24,10.0.0.0/16is the one that applies.CreateVpc is asynchronous: the response returns a VPC ID while creation continues in the background. Call DescribeVpcAttribute for status:
Creating: The VPC is still being provisioned.
Created: The VPC is ready to use.
You can create multiple non-default VPCs concurrently in the same region, subject to your account quotas.
Try it now
Test
RAM authorization
Action | Access level | Resource type | Condition key | Dependent action |
vpc:CreateVpc | create | *VPC
| None | None |
Request parameters
Parameter | Type | Required | Description | Example |
RegionId | string | Yes | The ID of the region to which the VPC belongs. You can call the DescribeRegions operation to query the most recent region list. | cn-hangzhou |
CidrBlock | string | No | VPC CIDR.
| 172.16.0.0/12 |
Ipv6CidrBlock | string | No | The IPv6 CIDR block of the VPC. If you enable IPv6 for a VPC, the system allocates an IPv6 CIDR block. To specify an IPv6 CIDR block, you must call the AllocateVpcIpv6Cidr operation to reserve the specified IPv6 CIDR block. | 2408:XXXX:0:6a::/56 |
VpcName | string | No | The name of the VPC. The name must be 1 to 128 characters in length and cannot start with | abc |
EnableIpv6 | boolean | No | Indicates whether IPv6 is enabled. Valid values:
| false |
Description | string | No | The description of the VPC. The description must be 1 to 256 characters in length and cannot start with | This is my first Vpc |
ResourceGroupId | string | No | The ID of the resource group. For more information about resource groups, see What is a resource group? | rg-acfmxazb4ph6aiy**** |
| Tag | array<object> | No | The tag of the resource. | |
object | No | |||
Key | string | No | The key of tag N to add to the resource. You can specify at most 20 tag keys. The tag key cannot be an empty string. The tag key can be at most 128 characters in length. It cannot start with | FinanceDept |
Value | string | No | The value of tag N to add to the resource. You can specify at most 20 tag values. The tag value can be an empty string. The tag value can be up to 128 characters in length, but cannot contain | FinanceJoshua |
DryRun | boolean | No | Specifies whether to perform a dry run, without performing the actual request. Valid values:
| false |
UserCidr | string | No | The user CIDR block. Separate user CIDR blocks with commas (,). You can specify up to three user CIDR blocks. For more information about user CIDR blocks, see the | 192.168.0.0/12 |
ClientToken | string | No | The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters. Note If you do not specify this parameter, the system automatically uses the request ID as the client token. The request ID may be different for each request. | 123e4567-e89b-12d3-a456-426655440000 |
Ipv6Isp | string | No | The type of the IPv6 CIDR block of the VPC. Valid values:
Note If you are allowed to use single-ISP bandwidth, you can set the value to ChinaTelecom, ChinaUnicom, or ChinaMobile. | BGP |
Ipv4IpamPoolId | string | No | The ID of the IP Address Manager (IPAM) pool of the IPv4 type. | ipam-pool-sycmt3p2a9v63i**** |
Ipv4CidrMask | integer | No | Allocate VPC from the IPAM address pool by inputting a mask. Note When creating a VPC with a specified IPAM address pool, at least one of the parameters CidrBlock or Ipv4CidrMask must be provided. | 12 |
EnableDnsHostname | boolean | No | Whether to enable the DNS hostname feature. Values:
| false |
Ipv6IpamPoolId | string | No | The ID of the IP Address Manager (IPAM) pool of the IPv6 type. | ipam-pool-bp1aq51kkfh477z03**** |
Ipv6CidrMask | integer | No | Add an IPv6 CIDR block from the IPAM pool to the VPC by entering a mask. | 56 |
Response elements
Element | Type | Description | Example |
object | The ID of the created VPC. | ||
VpcId | string | The ID of the created VPC. | vpc-bp15zckdt37pq72zv**** |
VRouterId | string | The ID of the vRouter that is automatically created by the system after the VPC is created. | vrt-bp1lhl0taikrteen8**** |
RequestId | string | The request ID. | 0ED8D006-F706-4D23-88ED-E11ED28DCAC0 |
RouteTableId | string | The ID of the route table that is automatically created by the system after the VPC is created. | vtb-bp145q7glnuzdv**** |
ResourceGroupId | string | The resource group ID. | rg-acfmxazb4ph6aiy**** |
Examples
Success response
JSON format
{
"VpcId": "vpc-bp15zckdt37pq72zv****",
"VRouterId": "vrt-bp1lhl0taikrteen8****",
"RequestId": "0ED8D006-F706-4D23-88ED-E11ED28DCAC0",
"RouteTableId": "vtb-bp145q7glnuzdv****",
"ResourceGroupId": "rg-acfmxazb4ph6aiy****"
}Error codes
HTTP status code | Error code | Error message | Description |
400 | TOKEN_PROCESSING | Action is processing. | |
400 | InvokeError | instance quota rule invoke error. | Failed to get rule data, please wait zai shi |
400 | InvalidParameter | Specified CIDR block is not valid | |
400 | ResourceNotAvailable | Resource you requested is not available in this region or zone. | |
400 | InvalidVpcName.Malformed | Specified VPC name is not valid. | |
400 | InvalidVpcDiscription.Malformed | Specified VPC description is not valid. | |
400 | QuotaExceeded.Vpc | VPC quota exceeded. | The number of VPCs in this account has reached the upper limit. |
400 | ResourceNotAvailable.Vpc | Resource you requested is not available in this region or zone. | |
400 | InvalidUserCidr.Quota | Specified UserCidr number is greater than 3. | |
400 | InvalidUserCidr.Malformed | Specified UserCidr overlapping in of 100.64.0.0/10. | The user CIDR block that you specify overlaps with 100.64.0.0/10. |
400 | InvalidResourceGroupId | The specified ResourceGroupId does not exist. | The specified resource group ID does not exist. |
400 | IllegalParam.Ipv6CidrBlock | %s | |
400 | OperationFailed.IPv6CidrNotReserved | %s | |
400 | MissingParam.EnableIpv6 | %s | |
400 | OperationUnsupported.Ipv6Feature | %s | |
400 | System.ServiceBusy | System is busy, please try later. | |
400 | IllegalParam.UserCidr | UserCidr is not a valid or strict address. | UserCidr is illegal. |
400 | OperationUnsupported.ResourceGroupId | ResourceGroup is not supported in this region. | |
400 | IllegalParam.EnableIpv6 | %s | |
400 | InvalidIpv6CidrBlock.Malformed | Specified Ipv6CidrBlock is not valid. | |
400 | UnsupportedFeature.Ipv6Isp | The Ipv6Isp feature is not supported. | The specified IPv6 ISP is not supported. |
400 | ResourceNotEnough.Ipv6Cidr | The specified resource of Ipv6Cidr is not enough. | IPv6 addresses are insufficient. |
400 | UnsupportedFeature.IPAM | VPCs cannot be created by using IPAM. | You cannot use IPAM to create a VPC. |
400 | IllegalParam.Ipv4CidrMask | The specified Ipv4CidrMask is illegal. | Invalid Ipv4CidrMask. |
400 | IllegalParam.IpamPool | The specified IPAM pool cannot be empty. | The IPAM pool cannot be empty. |
400 | OperationDenied.RequestRegionInvalid | The operation is not allowed because the request is not invoked in the region of the IPAM pool. | The operation is not allowed because the request is not invoked in the region of the IPAM pool. |
400 | OperationDenied.IpamPoolNotInRegion | The operation is not allowed because the IPAM pool not in specific region does not support creating VPC or associating CIDR for VPC. | The operation is not allowed because the IPAM pool not in specific region does not support creating VPC or associating CIDR for VPC. |
400 | MissingParam.CidrOrCidrMask | The CIDR or CIDR Mask must be input. | The CIDR or CIDR Mask must be input. |
400 | OperationDenied.CidrInExcludeCidrs | The operation is not allowed because the input CIDR is within the illegal CIDRs. | The operation is not allowed because the input CIDR is within the illegal CIDRs. |
400 | OperationDenied.AvailableCidrInsufficient | The operation is not allowed because available CIDR is insufficient. | The operation is not allowed because available CIDR is insufficient. |
400 | UnsupportedFeature.Ipam | IPAM is not supported in this region. | The IPAM feature is not supported in this region. |
400 | OperationDenied.CidrUnavailableInPool | The operation is not allowed because the CIDR is unavailable in the IPAM pool. | The operation is not allowed because the CIDR is unavailable in the IPAM pool. |
400 | IllegalParam.CidrBlockMask | The param of CidrBlock Mask [%s] is illegal. | The subnet mask of the CIDR block is invalid. |
400 | UnsupportedFeature.VpcDnsHostname | The feature of vpc dns hostname is unsupported. | The VPC private domain name function does not take effect in the current region. |
400 | OperationDenied.MaskOfCidrIsNotAllowed | The input mask or mask of the input CIDR is not allowed. | The input mask or mask of the input CIDR is not allowed. |
400 | IllegalParam.Ipv6Isp | The specified Ipv6Isp is illegal. | The specified Ipv6Isp is illegal. |
400 | IllegalParam.CidrMask | The input CIDR mask is illegal. | The input CIDR mask is illegal. |
400 | InvalidRegionId.NotFound | Specified value of "regionId" is not supported. | |
400 | UnsupportedFeature.DhcpOptionsSet | The feature of dhcp options set is unsupported. | The DHCP Options Set function does not take effect in the current region. |
400 | OperationDenied.CidrMaskTooLarge | The operation is denied because the CIDR mask %s is larger than the allocationMaxNetmask %s of the pool. | The operation is denied because the CIDR mask %s is larger than the allocationMaxNetmask %s of the pool. |
400 | OperationDenied.CidrMaskTooSmall | The operation is denied because the CIDR mask %s is less than the allocationMinNetmask %s of the pool. | The operation is denied because the CIDR mask %s is less than the allocationMinNetmask %s of the pool. |
500 | InternalError | The request processing has failed due to some unknown error. | |
403 | Forbidden | User not authorized to operate on the specified resource. | You do not have the permissions to manage the specified resource. Apply for the permissions and try again. |
404 | ResourceNotFound.IpamPool | The dependent IPAM pool is not found. | The dependent IPAM pool is not found. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.