CreateVpc

CreateVpc

1. API Description

This API is used to create a VPC.

Prerequisites

Before creating a VPC, call DescribeVpcAvailableRegions to check the availability regions for VPC creation.

Note

  • The quantity of VPCs you can create in one availability region is limited. If you need more, please contact Zenlayer Support.

  • This API is an async API. A VPC ID list is returned after the creation request is sent. However, it does not mean the creation has been completed. The status of the VPC will be CREATING during the creation. You can use DescribeVpcs to query the status of the VPC. If the status changes from CREATING to AVAILABLE, it means that the VPC has been created successfully; CREATE_FAILED means the VPC has been created failed. Any operations on the VPCs are not allowed while creating.

2. Input Parameters

The following request parameter list only provides API request parameters.

Parameter NameRequiredTypeDescription

vpcRegionId

Yes

String

Availability region ID of VPC.

cidrBlock

Yes

String

CIDR block of VPC.

vpcName

Yes

String

VPC name to be displayed.

This parameter can contain up to 64 characters. Only letters, numbers, - and periods (.) are supported.

resourceGroupId

No

String

Resource group ID.

If the value is not passed in, the VPC will be put into the default resource group. If no authorized default resource group found, the request will fail.

3. Output Parameters

Parameter NameTypeDescription

requestId

String

The unique request ID, which is returned for each request. RequestId is required for locating a problem.

vpcId

String

VPC ID.

4. Code Example

Create a VPC in CHI1.

POST /api/v2/bmc HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateVpc
<Common Request Params>

Request:
{
  "vpcRegionId": "CHI1",
  "cidrBlock": "10.0.0.0/8",
  "vpcName": "1122"
}

Response:
{
  "requestId": "T3811A0E7-C250-40A2-96AD-08AD759E1BC2",
  "response": {
    "requestId": "T3811A0E7-C250-40A2-96AD-08AD759E1BC2",
    "vpcId": "835957634816289496"
  }
}

5. Developer Resources

Zenlayer Cloud API 2.0 integrates SDKs to make it easier for you to call APIs. More programming languages will be supported.

6. Error Codes

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.​

HTTP Status CodeError CodeDescription

404

INVALID_VPC_REGION_NOT_FOUND

Availability region not found.

403

OPERATION_DENIED_VPC_REGION_EXCEED_LIMIT

Quantity of VPCs exceeds the limit of the availability region.

400

INVALID_PARAMETER_VPC_LAN_IP_NETMASK

Invalid netmask of CIDR block.

400

INVALID_PARAMETER_VPC_CIDR_BLOCK

Invalid CIDR block.

400

INVALID_PARAMETER_VPC_LAN_IP

Only CIDR block with private IP range is supported.

Last updated