Creates a VPC.

Note the following before you call this API action:

  • You can only specify one IP address range for a VPC. You can choose from the CIDR blocks 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, and their subnets. The netmask of the CIDR block can be 8 bits to 24 bits. The default CIDR block is 172.16.0.0/12.
  • The CIDR block cannot be modified after a VPC is created.
  • The number of cloud instances in each VPC cannot exceed 15,000.
  • A VRouter and a route table are automatically created after a VPC is created.
  • Up to three customer-side CIDR blocks are supported by a VPC. If a customer-side CIDR block is a subset of another customer-side CIDR block, the one with the shorter subnet mask takes effect. For example, if there are two CIDR blocks 10.0.0.0/8 and 10.1.0.0/16, only the CIDR block 10.0.0.0/8 takes effect.

Debug

Use OpenAPI Explorer to perform debug operations and generate SDK code examples.

Request parameters

Parameter Type Required? Example value Description
Action String Yes CreateVpc

The name of this action. Value: CreateVpc

RegionId String Yes cn-hangzhou

The ID of the region to which the VPC belongs. To query the region ID, call DescribeRegions.

CidrBlock String No 172.16.0.0/12

Optional. The IP address range of the VPC in CIDR block form. The following IP address ranges and their subnets can be used:

  • 10.0.0.0/8
  • 172.16.0.0/12 (default)
  • 192.168.0.0/16
ClientToken String No sha223ndd2333

Optional. The client token that guarantees the idempotence of the request. The value of this parameter is generated by a client. It is unique among all requests and can contain a maximum of 64 ASCII characters.

Description String No This is my first Vpc.

Optional. The description of the VPC. The description must be 2 to 256 characters in length. It must start with a letter, but cannot start with http:// or https://.

EnableIpv6 Boolean No false

Optional. Indicates whether to enable the IPv6 CIDR block. Valid values:

  • false (default): Disable the IPv6 CIDR block.
  • true: Enable the IPv6 CIDR block.
Ipv6CidrBlock String No 2408:4004:0:6axx::/56

Optional. The IPv6 CIDR block of the VPC.

ResourceGroupId String No rg-acfmxazb4ph6aiy****

Optional. The ID of the resource group.

UserCidr String No 189.16.0.0/12

Optional. The customer-side CIDR block. Separate multiple CIDR blocks by using commas (,). Up to three CIDR blocks are supported.

A VPC uses 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10, and the VPC CIDR block for intranet communication by default. If the ECS instances and Elastic IP Addresses (EIPs) that have access to the Internet (the ECS instances are assigned public IP addresses, or the ECS instances or their ENIs are associated with public IP addresses or configured with DNAT entries) visit the IP addresses outside the preceding CIDR blocks, the requests are forwarded to the Internet through the public IP addresses. If you want the requests (for example, from a VPC that is in a hybrid network environment built through VPN, Express Connect, or CEN) to be forwarded over the intranet according to a route table, you must set the destination CIDR blocks of the requests as the UserCidr of the corresponding ECS instance or Elastic Network Interface (ENI). After that, the requests from that VPC will be forwarded according to the route table, not through public IP addresses.

VpcName String No vpc-hp3ld1aq7kl4k7skh****

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

Response parameters

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

The ID of the VPC.

VRouterId String vrt-bp1lhl0taikrteen8****

The ID of the VRouter.

RouteTableId String vtb-bp145q7glnuzdv****

The ID of the route table.

RequestId String 0ED8D006-F706-4D23-88ED-E11ED28DCAC0

The ID of the request.

ResourceGroupId String rg-acfmxazb4ph6aiy****

The ID of the resource group.

Examples

Request example


https://vpc.aliyuncs.com/?Action=CreateVpc
&RegionId=cn-hangzhou
&<CommonParameters>

Response example

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

{
	"RequestId":"8B2F5262-6B57-43F2-97C4-971425462DFE",
	"ResourceGroupId":"rg-acfmxazb4ph****",
	"RouteTableId":"vtb-bp1krxxzp0c29****",
	"VpcId":"vpc-bp1qpo0kug3a20qqe****",
	"VRouterId":"vrt-bp1jcg5cmxjbl9xgc****"
}

Errors

HTTP status code Error code Error message Description
404 InvalidRegionId.NotFound Specified value of "regionId" is not supported. The specified RegionId does not exist.
400 InvalidParameter Specified CIDR block is not valid The specified CIDR block is invalid.
400 ResourceNotAvailable Resource you requested is not available in this region or zone. Vswitches are not supported in the specified region or zone.
400 InvalidVpcName.Malformed Specified VPC name is not valid. The format of the VPC name is invalid.
400 InvalidVpcDiscription.Malformed Specified VPC description is not valid. The format of the description is invalid.
403 Forbbiden User not authorized to operate on the specified resource. You are not authorized to operate on this resource.
400 QuotaExceeded.Vpc VPC quota exceeded. The number of VPCs under the account has reached the quota.
400 ResourceNotAvailable.Vpc Resource you requested is not available in this region or zone. The resource is unavailable in this region or zone.
400 InvalidParameter Specified UserCidr invalid format. The format of the customer-side CIDR block is invalid.
400 InvalidParameter Specified UserCidr Subnet mask is not valid . The subnet mask of the customer-side CIDR block is invalid.
400 InvalidUserCidr.Quota Specified UserCidr number is greater than 3. The UserCidr has reached the quota.
400 InvalidUserCidr.Malformed Specified UserCidr overlapping in of 100.64.0.0/10. The specified UserCidr overlaps with 100.64.0.0/10.
500 InternalError The request processing has failed due to some unknown error. The request failed to be processed due to unknown errors.

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