CreateSubnet

CreateSubnet

1. API Description

This API is used to create a subnet under a VPC.

Note

  • The quantity of subnets you can create under one VPC is limited. The IP range of the subnet under a VPC should be a subset of the VPC IP range.

  • IP ranges of subnets under the same VPC cannot be overlapped.

  • Call DescribeSubnetRegions to query regions supporting subnet creation.

2. Input Parameters

The following request parameter list only provides API request parameters.

Parameter Name
Required
Type
Description

vpcId

Yes

String

VPC ID.

name

Yes

String

Subnet name to be displayed.

This parameter must start and end with a number or a letter, containing 2 to 63 characters. Only letters, numbers, - and periods (.) are supported.

regionId

Yes

String

Region ID.

stackType

Yes

Subnet IP stack type.

cidrBlock

No

String

CIDR block of the subnet.

  • If the specified stack type (stackType) includes IPv4, this field is required.

  • The specified CIDR block must fall within the VPC’s CIDR range.

ipv6Type

No

Subnet IPv6 type. If the specified stack type (stackType) includes IPv6, this field is required.

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 under a VPC.

5. Developer Resources

Zenlayer Cloud API 2.0 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

400

INVALID_CIDR_BLOCK_FORMAT

Invalid CIDR block format.

400

INVALID_CIDR_BLOCK_NETMASK_RANGE

CIDR block range is invalid.

400

INVALID_CIDR_BLOCK_NOT_EMPTY

CIDR block cannot be empty.

400

INVALID_CIDR_BLOCK_NOT_LAN_IP

CIDR block must be a private IP range.

400

INVALID_CIDR_IPV6_ONLY

IPv6 stack type is specified only.

400

INVALID_IP_BROADCAST_ADDRESS

The IP address cannot be a broadcast address.

400

INVALID_PARAMETER_SUBNET_CIDR_NOT_BELONG_VPC

The subnet does not belong to the specified VPC.

400

INVALID_PARAMETER_SUBNET_IPV6_TYPE_NOT_FOUND

ipv6Type is not found.

404

INVALID_REGION_NOT_FOUND

Region does not found.

400

INVALID_REGION_NOT_ON_SALE

Subnet is not available for sale in the specified region.

404

INVALID_VPC_NOT_FOUND

Global VPC does not exist.

400

OPERATION_DENIED_REGION_NOT_SUPPORT_PUB_IPV6

Public IPv6 is not supported in the specified region.

400

OPERATION_DENIED_SUBNET_CIDR_CONFLICT

Subnet CIDR ranges conflict.

400

OPERATION_DENIED_VPC_NOT_SUPPORT_PRI_IPV6

Private IPv6 is not supported for the specified global VPC.

400

OPERATION_DENIED_CIDR_BLOCK_IS_EXIST

CIDR block already exists.

Last updated