DescribeSubnets - Amazon Elastic Compute Cloud
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.


Describes one or more of your subnets.

For more information, see Your VPC and subnets in the Amazon Virtual Private Cloud User Guide.

Request Parameters

The following parameters are for this specific action. For more information about required and optional parameters that are common to all actions, see Common Query Parameters.


Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Type: Boolean

Required: No


One or more filters.

  • availability-zone - The Availability Zone for the subnet. You can also use availabilityZone as the filter name.

  • availability-zone-id - The ID of the Availability Zone for the subnet. You can also use availabilityZoneId as the filter name.

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

  • cidr-block - The IPv4 CIDR block of the subnet. The CIDR block you specify must exactly match the subnet's CIDR block for information to be returned for the subnet. You can also use cidr or cidrBlock as the filter names.

  • default-for-az - Indicates whether this is the default subnet for the Availability Zone (true | false). You can also use defaultForAz as the filter name.

  • ipv6-cidr-block-association.ipv6-cidr-block - An IPv6 CIDR block associated with the subnet.

  • ipv6-cidr-block-association.association-id - An association ID for an IPv6 CIDR block associated with the subnet.

  • ipv6-cidr-block-association.state - The state of an IPv6 CIDR block associated with the subnet.

  • ipv6-native - Indicates whether this is an IPv6 only subnet (true | false).

  • outpost-arn - The Amazon Resource Name (ARN) of the Outpost.

  • owner-id - The ID of the Amazon Web Services account that owns the subnet.

  • state - The state of the subnet (pending | available).

  • subnet-arn - The Amazon Resource Name (ARN) of the subnet.

  • subnet-id - The ID of the subnet.

  • tag:<key> - The key/value combination of a tag assigned to the resource. Use the tag key in the filter name and the tag value as the filter value. For example, to find all resources that have a tag with the key Owner and the value TeamA, specify tag:Owner for the filter name and TeamA for the filter value.

  • tag-key - The key of a tag assigned to the resource. Use this filter to find all resources assigned a tag with a specific key, regardless of the tag value.

  • vpc-id - The ID of the VPC for the subnet.

Type: Array of Filter objects

Required: No


The maximum number of results to return with a single call. To retrieve the remaining results, make another call with the returned nextToken value.

Type: Integer

Valid Range: Minimum value of 5. Maximum value of 1000.

Required: No


The token for the next page of results.

Type: String

Required: No


One or more subnet IDs.

Default: Describes all your subnets.

Type: Array of strings

Required: No

Response Elements

The following elements are returned by the service.


The token to use to retrieve the next page of results. This value is null when there are no more results to return.

Type: String


The ID of the request.

Type: String


Information about one or more subnets.

Type: Array of Subnet objects


For information about the errors that are common to all actions, see Common client error codes.


Example 1

This example describes the subnets.

Sample Request &AUTHPARAMS

Sample Response

<requestId>1927e20c-0ed0-4a02-a6d7-d955fbd2d13c</requestId> <subnetSet> <item> <subnetId>subnet-0bb1c79de301436ee</subnetId> <subnetArn>arn:aws:ec2:us-east-2:111122223333:subnet/subnet-0bb1c79de3EXAMPLE</subnetArn> <state>available</state> <ownerId>111122223333</ownerId> <vpcId>vpc-0ee975135dEXAMPLE</vpcId> <cidrBlock></cidrBlock> <ipv6CidrBlockAssociationSet/> <availableIpAddressCount>251</availableIpAddressCount> <availabilityZone>us-east-2c</availabilityZone> <availabilityZoneId>use2-az3</availabilityZoneId> <defaultForAz>false</defaultForAz> <mapPublicIpOnLaunch>false</mapPublicIpOnLaunch> <assignIpv6AddressOnCreation>false</assignIpv6AddressOnCreation> </item> <item> <subnetId>subnet-02bf4c428bf44ebce</subnetId> <subnetArn>arn:aws:ec2:us-east-2:111122223333:subnet/subnet-02bf4c428bEXAMPLE</subnetArn> <state>available</state> <ownerId>111122223333</ownerId> <vpcId>vpc-07e8ffd50fEXAMPLE</vpcId> <cidrBlock></cidrBlock> <ipv6CidrBlockAssociationSet> <item> <ipv6CidrBlock>2600:1f16:115:200::/64</ipv6CidrBlock> <associationId>subnet-cidr-assoc-002afb9f3cEXAMPLE</associationId> <ipv6CidrBlockState> <state>associated</state> </ipv6CidrBlockState> </item> </ipv6CidrBlockAssociationSet> <availableIpAddressCount>251</availableIpAddressCount> <availabilityZone>us-east-2b</availabilityZone> <availabilityZoneId>use2-az2</availabilityZoneId> <defaultForAz>false</defaultForAz> <mapPublicIpOnLaunch>false</mapPublicIpOnLaunch> <assignIpv6AddressOnCreation>false</assignIpv6AddressOnCreation> </item> </subnetSet> </DescribeSubnetsResponse>

Example 2

This example uses filters to describe any subnet you own that is in the VPC with the ID vpc-0056ae9ffdEXAMPLE or vpc-0096ae9ffdEXAMPLE, and whose state is available.

Sample Request &Filter.1.Name=vpc-id &Filter.1.Value.1=vpc-0056ae9ffdEXAMPLE &Filter.1.Value.2=vpc-0096ae9ffdEXAMPLE &Filter.2.Name=state &Filter.2.Value.1=available &AUTHPARAMS

Sample Response

<DescribeSubnetsResponse xmlns=""> <requestId>43e9cb52-0e10-40fe-b457-988c8fbfea26</requestId> <subnetSet> <item> <subnetId>subnet-0f8c6c2f37EXAMPLE</subnetId> <subnetArn>arn:aws:ec2:us-west-2:123456789012:subnet/subnet-0f8c6c2f37903e9dc</subnetArn> <state>available</state> <ownerId>123456789012</ownerId> <vpcId>vpc-vpc-0056ae9ffdEXAMPLE</vpcId> <cidrBlock></cidrBlock> <ipv6CidrBlockAssociationSet/> <availableIpAddressCount>65531</availableIpAddressCount> <availabilityZone>us-west-2b</availabilityZone> <availabilityZoneId>usw2-az2</availabilityZoneId> <defaultForAz>false</defaultForAz> <mapPublicIpOnLaunch>false</mapPublicIpOnLaunch> <assignIpv6AddressOnCreation>false</assignIpv6AddressOnCreation> </item> </subnetSet> </DescribeSubnetsResponse>

See Also

For more information about using this API in one of the language-specific Amazon SDKs, see the following: