CreateSubnet

1. API Description

This API (CreateSubnet) is used to create a subnet under a VPC.

circle-info

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.

dhcpOptionsSetId

No

String

DHCP options set to be associated.

ipv6CidrBlockId

No

String

ID of the public IPv6 CIDR block.

This field can only be specified when ipv6Type is Public.

If not specified, it will be allocated from the system's default IP pool.

ipv6MaskLength

No

Integer

The size of the IPv6 CIDR prefix assigned to the instance.

This parameter must be used together with the ipv6CidrBlockId parameter.

The default value is 96 if not explicitly provided.

The minimum value must be greater than or equal to the prefix of the specified ipv6CidrBlockId, and the maximum value cannot exceed 96.

Value range: [-, 96]

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 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

400

INVALID_CIDR_BLOCK_FORMAT

Invalid CIDR block format.

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_BLOCK_STATUS

The CIDR block state is invalid.

404

INVALID_CIDR_IPV6_NOT_FOUND

IPv6 CIDR block does not exist

400

INVALID_CIDR_IPV6_ONLY

IPv6 stack type is specified only.

400

INVALID_CIDR_REGION_MISMATCH

The subnet region does not match the IPv6 CIDR block region.

404

INVALID_DHCP_OPTIONS_SET_NOT_FOUND

The DHCP options set is not found.

400

INVALID_IP_BROADCAST_ADDRESS

The IP address cannot be a broadcast address.

400

INVALID_MAST_LENGTH

The IPv6 address mask length must be greater than the subnet IPv6 prefix length.

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

Specified availability zone does not exist.

400

INVALID_REGION_NOT_ON_SALE

Subnet is not available for sale in the specified region.

400

INVALID_SUBNET_NETMASK_MAX_RANGE

Subnet mask length exceeds the maximum value.

404

INVALID_VPC_NOT_FOUND

The global VPC does not exist.

400

OPERATION_DENIED_CIDR_BLOCK_IS_EXIST

CIDR block already exists.

400

OPERATION_DENIED_NO_AVAILABLE_CIDR

No available CIDR block.

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.

Last updated