Creates a VPC.

Note the following before creating a VPC:
  • You must specify the IP address range of the VPC in the form of the CIDR block. You can use the standard private IP address ranges or their subnets as the CIDR block of the VPC. The size of the CIDR block mask can be 8 bits to 24 bits. The default CIDR block is 172.16.0.0/12.

  • The CIDR block cannot be modified after the VPC has been created.

  • The number of cloud product 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 can be added to a VPC. If one customer-side CIDR block is the subset of another CIDR block, the one with the shorter mask takes effect. For example, for the CIDR blocks 10.0.0.0/8 and 10.1.0.0/16, the customer-side CIDR block 10.0.0.0/8 is the CIDR block that takes effect.

Debug

By using OpenAPI Explorer, you can easily debug APIs, automatically generate SDK code examples, and quickly search for APIs.

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 region ID of the VPC to be created.

To query the region ID, call DescribeRegions.

CidrBlock String No 172.16.0.0/12

The IP address range of the VPC in the CIDR block form. You can use the following IP address ranges or their subnets:

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

A client token used to guarantee the idempotence of requests.

This parameter value is generated by the client and must be unique. It must be 1 to 64 ASCII characters in length.

Description String No This is my first Vpc.

 The description of the VPC.

The description can contain 2-256 characters. It must start with an English letter, but it cannot start with http:// or https://.

EnableIpv6 Boolean No 0

Indicates whether to enable the IPv6 CIDR block. Default value: false.

Valid values: false | true

Ipv6CidrBlock String No 223.223.213.122

The IPv6 CIDK block of the VPC.

ResourceGroupId String No 123

The ID of the resource group.

UserCidr String No 189.16.0.0/12

The customer-side CIDR block. Separate multiple CIDR blocks with commas. You can add up to three CIDR blocks.

VpcName String No Vpc-1

The name of the VPC.

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

Response parameters

Parameter Type Example value Description
RequestId String 0ED8D006-F706-4D23-88ED-E11ED28DCAC0 The ID of the request.
VpcId String vpc-bp15zckdt37pq72zvw30k The ID of the VPC.
VRouterId String vrt-bp1lhl0taikrteen80oxx The ID of the VRouter.
RouteTableId String vtb-bp145q7glnuzdvzu21pom The ID of the route table.
ResourceGroupId String rg-acfmxazb4ph6aiy

The ID of the resource group.

Examples

Request example

https://vpc.aliyuncs.com/?Action=CreateVpc
&RegionId=cn-hangzhou
&CidrBlock=10.10.0.0/24
&CommonParameters
Response example
  • XML format

    <CreateVpcResponse>
      <ResourceGroupId>rg-acfmxazb4ph6aiy</ResourceGroupId>
      <RequestId>8B2F5262-6B57-43F2-97C4-971425462DFE</RequestId>
      <RouteTableId>vtb-bp1krxxzp0c29fmontbal</RouteTableId>
      <VRouterId>vrt-bp1jcg5cmxjbl9xgc58bw</VRouterId>
      <VpcId>vpc-bp1qpo0kug3a20qqe9h7v</VpcId>
    </CreateVpcResponse>
    
  • JSON format

    {
    	"RequestId":"8B2F5262-6B57-43F2-97C4-971425462DFE",
    	"ResourceGroupId":"rg-acfmxazb4ph6aiy",
    	"RouteTableId":"vtb-bp1krxxzp0c29fmontbal",
    	"VpcId":"vpc-bp1qpo0kug3a20qqe9h7v",
    	"VRouterId":"vrt-bp1jcg5cmxjbl9xgc58bw"
    }

Error codes

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 CIDR block is invalid.
400 ResourceNotAvailable Resource you requested is not available in this region or zone. You cannot create a VSwitch in this region or zone.
400 InvalidVpcName.Malformed Specified VPC name is not valid. The format of the name of the specified VPC is invalid.
400 QuotaExceeded.Vpc VPC quota exceeded. The maximum number of VPCs for the account has been reached.
403 Forbbiden User not authorized to operate on the specified resource. You are not authorized to operate on this resource.
400 ResourceNotAvailable.Vpc Resource you requested is not available in this region or zone. The resource that you are requesting is not available in the region or zone.
400 InvalidVpcName.Malformed Specified VPC name is not valid. The format of the name of the specified VPC is invalid.
400 InvalidParameter Specified UserCidr invalid format. The specified CIDR block is invalid.
400 InvalidParameter Specified UserCidr Subnet mask is not valid . The specified subnet mask for UserCidr is invalid.
400 InvalidUserCidr.Quota Specified UserCidr number is greater than 3. The number of UserCird has reached the quota.
400 InvalidUserCidr.Malformed Specified UserCidr overlapping in of 100.64.0.0/10. The specified UserCird overlaps with 100.64.0.0/10.
500 InternalError The request processing has failed due to some unknown error. An error occurred while the request was being processed.

See common errors