Describes one or more of your subnets. It is possible to use one or more filter values.

Request Parameters#

  • Filter.N — One or more filters.

    • Type: List of Filter objects

    • Required: No

  • VpcId — The ID of the VPC.

    • Type: String

    • Required: No

Supported Filters#

  • availability-zone — The availability zone ID. You can use availabilityZone instead.

  • available-ip-address-count — The number of available IPv4 addresses in the subnet.

  • default-for-az — Indicates whether the subnet is default. You can use defaultForAz instead.

  • subnetId — The ID of the subnet.

  • tag-key — The tag key. Such a filter allows you to get resources with the specified key and any value.

  • tag:<tag-key> — The key/value a pair of a tag. The tag key is passed in the filter name, while the tag value is used as the filter value.

  • vpc-id — The ID of the VPC.

Response Elements#

  • requestId — The request ID

    • Type: String

  • subnetSet — Information about subnets.

    • Type: List of Subnet objects


c2-ec2 DescribeSubnets

c2-ec2 DescribeSubnets VpcId <vpc_id>

c2-ec2 DescribeSubnets Filter.1.Name subnet-id Filter.1.Value.1 <subnet_id>

c2-ec2 DescribeSubnets Filter.1.Name tag:<tag-key> Filter.1.Value <tag-value>

c2-ec2 DescribeSubnets Filter.1.Name tag-key Filter.1.Value <tag-key>