CreateVpc
Creates a virtual private cloud (VPC).
Operation description
When you call this operation to create a VPC, take note of the following items:
-
You can specify only one primary Secondary CIDR block for a VPC. You can add secondary Secondary CIDR blocks to expand the CIDR blocks.
-
After a VPC is created, you can expand or shrink the IPv4 CIDR block within the original IPv4 CIDR block. If you shrink the IPv4 CIDR block of the VPC and some IP addresses in use fall outside the destination CIDR block, the modification fails.
-
Each VPC supports up to 300,000 private network addresses for cloud resources, and the quota cannot be upgraded.
-
After you create a VPC, the system performs automatic creation of a vRouter for routing and a route table.
-
Each VPC supports up to three user CIDR blocks. If multiple user CIDR blocks overlap, the CIDR block with the shorter mask takes effect. For example, if 10.0.0.0/16 and 10.0.0.0/24 are specified, 10.0.0.0/16 takes effect.
-
The CreateVpc operation is asynchronous. The system returns an instance ID, but the VPC is not yet created and the creation task is still running in the background. You can call the DescribeVpcAttribute operation to query the creation status of the VPC:
If the VPC is in the Creating state, the VPC is being created.
If the VPC is in the Created state, the VPC is created.
-
The CreateVpc operation supports concurrent creation of non-default VPCs in the same region, subject to 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 region ID of the VPC. You can call the DescribeRegions operation to query the most recent region list. |
cn-hangzhou |
| CidrBlock |
string |
No |
The CIDR block of the VPC.
|
172.16.0.0/12 |
| Ipv6CidrBlock |
string |
No |
The IPv6 CIDR block of the VPC. When you enable IPv6 for the VPC, the system will assign an IPv6 CIDR block. To specify an IPv6 CIDR block, you must first invoke the AllocateVpcIpv6Cidr operation to reserve the specified IPv6 CIDR block and pass it in. |
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 |
Specifies whether to enable IPv6. 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 resource group ID. For more information about resource groups, see What is a resource group?. |
rg-acfmxazb4ph6aiy**** |
| Tag |
array<object> |
No |
The tags of the resource. |
|
|
object |
No |
The tags. |
||
| Key |
string |
No |
The tag key of the resource. You can specify up to 20 tag keys. If you specify this parameter, you cannot enter an empty string. A tag key can be up to 128 characters in length. It cannot start with |
FinanceDept |
| Value |
string |
No |
The tag value of the resource. You can specify up to 20 tag values. If you specify this parameter, you can enter an empty string. A tag value can be up to 128 characters in length. It cannot start with |
FinanceJoshua |
| DryRun |
boolean |
No |
Specifies whether to only perform a dry run for the request. Valid values:
|
false |
| UserCidr |
string |
No |
The user CIDR block. Separate multiple CIDR blocks with commas (,). You can specify up to three 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 value, but you must ensure that it is unique among different requests. The client token can contain only ASCII characters. Note
If you do not specify this parameter, the system automatically uses the RequestId of the API request as the ClientToken. The RequestId of each API request is unique. |
123e4567-e89b-12d3-a456-426655440000 |
| Ipv6Isp |
string |
No |
The IPv6 ISP of the VPC. Valid values:
Note
If you are added to the whitelist for single-line bandwidth, you can set this parameter to ChinaTelecom, ChinaUnicom, or ChinaMobile. |
BGP |
| Ipv4IpamPoolId |
string |
No |
The instance ID of the IPv4 IPAM pool. |
ipam-pool-sycmt3p2a9v63i**** |
| Ipv4CidrMask |
integer |
No |
The subnet mask length used to allocate a VPC from the IPAM pool. Note
When you specify an IPAM pool to create a VPC, you must specify at least one of the CidrBlock and Ipv4CidrMask parameters. |
12 |
| EnableDnsHostname |
boolean |
No |
Specifies whether to enable the DNS hostname feature. Valid values:
|
false |
| Ipv6IpamPoolId |
string |
No |
The instance ID of the IPv6 IPAM pool. |
ipam-pool-bp1aq51kkfh477z03**** |
| Ipv6CidrMask |
integer |
No |
The subnet mask length used to add an IPv6 CIDR block to the VPC from the IPAM pool. |
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 for routing that is generated through automatic creation after you create a VPC. |
vrt-bp1lhl0taikrteen8**** |
| RequestId |
string |
The request ID. |
0ED8D006-F706-4D23-88ED-E11ED28DCAC0 |
| RouteTableId |
string |
The ID of the route table for routing that is generated through automatic creation after you create a VPC. |
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. | The resource group feature is not enabled. |
| 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. |
| 400 | Mismatch.ParamIpv6IspAndIpamPoolIpv6Isp | The specified IPv6 ISP %s does not match the IPAM pool's IPv6 ISP %s. | The specified IPv6 ISP does not match the IPv6 ISP configured in the IPAM pool. |
| 400 | IllegalParam.CidrBlock | The param of CidrBlock [%s] is illegal. | The CidrBlock parameter is set to an invalid value. |
| 400 | QuotaExceeded.IpamVpcCidrPerConflictDetectionScope | The number of IPv4 VPC CIDRs per conflict detection scope has exceeded the quota limit. | The number of IPv4 VPC CIDRs per conflict detection scope has exceeded the quota limit. |
| 400 | IncorrectStatus.IpamScope | The status of the specified IPAM scope is incorrect. | The status of the specified IPAM scope is incorrect. |
| 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.