For the complete documentation index, see llms.txt. This page is also available as Markdown.

CreateSubnet

1. API Description

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

Notes

  • The number of subnet resources that can be created in the same VPC is also limited, and the CIDR block of each subnet must fall within the CIDR block of the VPC.

  • Within the same VPC, the CIDR blocks of subnets cannot overlap.

  • Call the DescribeSubnetRegions interface to query whether subnet creation is supported in a region.

2. Input Parameters

The following request parameter list only provides API request parameters.

Parameter Name
Required
Type
Description

vpcId

Yes

String

ID of the VPC to which the subnet is to be added.

It can be obtained by calling DescribeVpcs.

name

Yes

String

The subnet name.

Length: 2 to 63 characters.

Only letters, digits, hyphens (-), underscores (_), slashes (/), periods (.) and spaces are allowed.

Must start and end with a digit or a letter.

regionId

Yes

String

ID of the region where the subnet is located.

It must be one of the regions where the VPC is located.

It can be obtained by calling DescribeRegions.

stackType

Yes

The IP stack type of the subnet. Valid values: IPv4 (IPv4 only), IPv4_IPv6 (dual-stack IPv4 and IPv6), IPv6 (IPv6 only).

cidrBlock

No

String

IPv4 CIDR block of the subnet.

Required when stackType contains IPv4.

The specified CIDR block must fall within the CIDR range of the VPC.

ipv6Type

No

Type of the IPv6 address.

Required when stackType contains IPv6.

dhcpOptionsSetId

No

String

ID of the DHCP options set to be bound.

It can be obtained by calling DescribeDhcpOptionsSets.

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

1. Create a subnet. The stack type is IPv4_IPv6 and the IPv6 address is public.

2. Create an IPv4-only subnet. ipv6Type does not need to be specified when the stack type is IPv4.

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_STATUS

The CIDR block state is invalid.

404

INVALID_CIDR_IPV6_NOT_FOUND

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

The IPv6 address mask length must be greater than or equal to 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

The parameter ipv6Type is missing.

404

INVALID_REGION_NOT_FOUND

The specified region 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