CreateSubnet
CreateVpc
1. API Description
This API is used to create a subnet.
Prerequisites
Before creating a subnet, call DescribeSubnetAvailableResources
to check the zones available for subnet creation.
Note
The quantity of subnets you can create in one zone is limited. If you need more, please contact Zenlayer Support.
Create a subnet separately if you need a Layer 2 network; create subnets in a VPC if you need a Layer 3 network. You are recommended to create subnets in a VPC because they can communicate with each other. You can also create a subnet separately and then upgrade it into a VPC.
This API is an async API. A subnet ID list is returned after the creation request is sent. However, it does not mean the creation has been completed. The status of the subnet will be
CREATING
during the creation. You can useDescribeSubnets
to query the status of the subnet. If the status changes fromCreating
toAvailable
, it means that the subnet has been created successfully;CREATE_FAILED
means the subnet has been created failed. Any operations on the subnets are not allowed while creating.
2. Input Parameters
The following request parameter list only provides API request parameters.
Parameter Name | Required | Type | Description |
---|---|---|---|
zoneId | Yes | String | Zone ID to which the subnet belongs. |
cidrBlock | Yes | String | CIDR block of the subnet. The optional values are as follows:
If the subnet is going to be added into a VPC, the value should be in the range of VPC CIDR block and not overlap with IP ranges of other subnets in this VPC. |
subnetName | Yes | String | Subnet 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 subnet will be put into the default resource group. If no authorized default resource group found, the request will fail. If the subnet is going to be added into a VPC, this parameter will be ignored. The created subnet will be added into the resource group of the VPC. |
vpcId | No | String | VPC ID. |
3. Output Parameters
Parameter Name | Type | Description |
---|---|---|
requestId | String | The unique request ID, which is returned for each request. RequestId is required for locating a problem. |
subnetId | String | Subnet ID. |
4. Code Example
Create a subnet in zone SIN-B
.
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 Code | Error Code | Description |
---|---|---|
403 | OPERATION_DENIED_ZONE_NOT_SUPPORT_SUBNET | Subnet not supported in the zone. |
404 | INVALID_VPC_NOT_FOUND | VPC not found. |
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 does not belong to the availability region of VPC. |
400 | INVALID_PARAMETER_SUBNET_CIDR_BLOCK | Invalid CIDR block. |
400 | INVALID_PARAMETER_SUBNET_LAN_IP_NETMASK | Invalid netmask of CIDR block. |
400 | INVALID_PARAMETER_SUBNET_LAN_IP | Only CIDR block with private IP range is supported. |
403 | OPERATION_DENIED_SUBNET_EXCEED_LIMIT | Quantity of subnets exceeds the limit of the zone. |
403 | OPERATION_DENIED_VPC_ZONE_SUBNET_EXCEED_LIMIT | Quantity of subnets exceeds the limit of the availability region of VPC. |
400 | INVALID_PARAMETER_VPC_SUBNET_OVER_LAP | Overlapped CIDR blocks of subnets in VPC. |
404 | INVALID_ZONE_NOT_FOUND | Zone not found. |
400 | INVALID_PARAMETER_SUBNET_CIDR_NOT_BELONG_VPC | CIDR block of subnet not in the IP range of VPC. |
Last updated