ec2.subnets.create

Create a subnet: a range of the VPC in one availability zone

POST /ec2/api/vpcs/{id}/subnetsIAM ec2:CreateSubnetChanges state

An instance launched with `subnetId` gets an address in the range and runs in the subnet’s zone. Ranges are /16 to /28, inside the VPC and not overlapping another subnet.

Request syntax

POST /ec2/api/vpcs/{id}/subnets
{
  "cidrBlock": "string",
  "availabilityZoneId": "string",
  "name": "string",
  "tags": "map of string"
}

Path parameters

  • idRequired

    string

    Constraints: uuid

Request body

  • cidrBlockRequired

    string

    IPv4 range inside the VPC, e.g. 10.0.1.0/24

    Constraints: 9-18 chars

  • availabilityZoneIdOptional

    string

    The zone (e.g. de1b); default de1a

    Constraints: /^[a-z]+[0-9]+[a-z]$/

  • nameOptional

    string

    A display name; omitted: none

    Constraints: max 64 chars

  • tagsOptional

    map of string

    Tags for the new resource, e.g. {"env": "prod", "project": "shop"}. Keys your organization marks required must be present, or the create is refused with the missing keys (GET /tags/api/keys lists them).

    Constraints: key=value

Response

201: `data` is the new subnet: id, vpcId, availabilityZoneId, name, cidrBlock, availableIpCount.

A JSON response is wrapped as { "success": true, "data": … }; the CLI prints the whole body with --json.

Errors

  • 400The request does not pass the schema above. The body is { "error": …, "issues": […] }, one issue per field.
  • 401No credentials, or an access key that is unknown, revoked or expired.
  • 403The caller's policies do not allow ec2:CreateSubnet on this resource. The body names the action and the resource, and the refusal is recorded in the audit log.
  • 404The resource does not exist in your organization.

Examples

The required parameters only, with example values. Replace id and the other placeholders with your own.

dcloud ec2 subnets create id --cidr-block example

Generated from the API description, the same one the API checks requests against and the CLI is built from. MCP tool: dcloud_ec2_subnets_create.