AssociateVpcSubnet

AssociateVpcSubnet

1. API Description

This API is used to add a subnet into a VPC.

Note

  • This API is an async API. A request ID is returned after the request is sent. However, it does not mean the binding has been completed. You can use DescribeSubnets to query the status.

  • Only operations on instances in RUNNING status are supported.

  • CIDR block of the subnet should be in the range of VPC CIDR block and not overlap with IP ranges of other subnets in this VPC.

  • Zone of the subnet should be in the availability region of the VPC. You can call DescribeVpcAvailableRegions to check the zones in the availability region.

  • No action will be made against the subnet already in the VPC.

  • Both the status of VPC and subnet should be AVAILABLE.

2. Input Parameters

The following request parameter list only provides API request parameters.

Parameter NameRequiredTypeDescription

subnetId

Yes

String

Subnet ID.

vpcId

Yes

String

VPC ID.

3. Output Parameters

Parameter NameTypeDescription

requestId

String

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

4. Code Example

Add a subnet into a VPC.

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

Request:
{
  "subnetId": "426257512392561112",
  "vpcId": "835957634816289496"
}

Response:
{
  "requestId": "T7D2DD189-870C-4B13-B812-0A3C7B8D83F1",
  "response": {
    "requestId": "T7D2DD189-870C-4B13-B812-0A3C7B8D83F1"
  }
}

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_NOT_FOUND

VPC not found.

404

INVALID_SUBNET_NOT_FOUND

Subnet not found.

403

OPERATION_DENIED_SUBNET_STATUS_NOT_SUPPORT

Subnet status not supported.

403

OPERATION_DENIED_SUBNET_ASSOCIATED_OTHER_VPC

Subnet is in other VPC.

403

OPERATION_DENIED_VPC_STATUS_NOT_SUPPORT

VPC status not supported.

403

OPERATION_DENIED_NO_AVAILABLE_VPC_REGION

Invalid availability region ID of VPC.

403

OPERATION_DENIED_ZONE_NOT_BELONG_VPC

Zone of subnet does not belong to the availability region of VPC.

403

OPERATION_DENIED_VPC_ZONE_SUBNET_EXCEED_LIMIT

Quantity of subnets exceeds the limit of the zone.

400

INVALID_PARAMETER_VPC_SUBNET_OVER_LAP

Overlapped CIDR blocks of subnets in VPC.

Last updated