Skip to content

describe_volumes async

describe_volumes(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    volume_ids: Optional[VolumeIdStringList] = None,
    include_managed_resources: Optional[Boolean] = None,
    dry_run: Optional[Boolean] = None,
    filters: Optional[FilterList] = None,
    next_token: Optional[String] = None,
    max_results: Optional[Integer] = None,
) -> DescribeVolumesResult

Describes the specified EBS volumes or all of your EBS volumes.

If you are describing a long list of volumes, we recommend that you paginate the output to make the list more manageable. For more information, see Pagination.

For more information about EBS volumes, see Amazon EBS volumes in the Amazon EBS User Guide.

We strongly recommend using only paginated requests. Unpaginated requests are susceptible to throttling and timeouts.

The order of the elements in the response, including those within nested structures, might vary. Applications should not assume the elements appear in a particular order.

Parameters:

  • volume_ids (Optional[VolumeIdStringList], default: None ) –

    The volume IDs. If not specified, then all volumes are included in the response.

  • include_managed_resources (Optional[Boolean], default: None ) –

    Indicates whether to include managed resources in the output. If this parameter is set to true, the output includes resources that are managed by Amazon Web Services services, even if managed resource visibility is set to hidden.

  • dry_run (Optional[Boolean], default: None ) –

    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.

  • filters (Optional[FilterList], default: None ) –

    The filters.

    • attachment.attach-time - The time stamp when the attachment initiated.

    • attachment.delete-on-termination - Whether the volume is deleted on instance termination.

    • attachment.device - The device name specified in the block device mapping (for example, /dev/sda1).

    • attachment.instance-id - The ID of the instance the volume is attached to.

    • attachment.status - The attachment state (attaching | attached | detaching).

    • availability-zone - The Availability Zone in which the volume was created.

    • availability-zone-id - The ID of the Availability Zone in which the volume was created.

    • create-time - The time stamp when the volume was created.

    • encrypted - Indicates whether the volume is encrypted (true | false)

    • fast-restored - Indicates whether the volume was created from a snapshot that is enabled for fast snapshot restore (true | false).

    • multi-attach-enabled - Indicates whether the volume is enabled for Multi-Attach (true | false)

    • operator.managed - A Boolean that indicates whether this is a managed volume.

    • operator.principal - The principal that manages the volume. Only valid for managed volumes, where managed is true.

    • size - The size of the volume, in GiB.

    • snapshot-id - The snapshot from which the volume was created.

    • status - The state of the volume (creating | available | in-use | deleting | deleted | error).

    • tag: - 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.

    • volume-id - The volume ID.

    • volume-type - The Amazon EBS volume type (gp2 | gp3 | io1 | io2 | st1 | sc1| standard)

  • next_token (Optional[String], default: None ) –

    The token returned from a previous paginated request. Pagination continues from the end of the items returned by the previous request.

  • max_results (Optional[Integer], default: None ) –

    The maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. For more information, see Pagination.

Raises:

Examples:

To describe all volumes This example describes all of your volumes in the default region.

>>> await client.describe_volumes()
To describe volumes that are attached to a specific instance
This example describes all volumes that are both attached to the instance with the ID i-1234567890abcdef0 and set to delete when the instance terminates.
>>> await client.describe_volumes(filters=[{'Values': ['i-1234567890abcdef0'], 'Name': 'attachment.instance-id'}, {'Values': ['true'], 'Name': 'attachment.delete-on-termination'}])
Source code in docs_src/capo_ec2/_services/async_ec2.py
async def describe_volumes(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    volume_ids: Optional[
        "capo_ec2.types.volume_id_string_list.VolumeIdStringList"
    ] = None,
    include_managed_resources: Optional["capo_ec2.types.boolean.Boolean"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    filters: Optional["capo_ec2.types.filter_list.FilterList"] = None,
    next_token: Optional["capo_ec2.types.string.String"] = None,
    max_results: Optional["capo_ec2.types.integer.Integer"] = None,
) -> "capo_ec2.types.describe_volumes_result.DescribeVolumesResult":
    """<p>Describes the specified EBS volumes or all of your EBS volumes.</p> <p>If you are describing a long list of volumes, we recommend that you paginate the output to make the list more manageable. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Query-Requests.html#api-pagination">Pagination</a>.</p> <p>For more information about EBS volumes, see <a href="https://docs.aws.amazon.com/ebs/latest/userguide/ebs-volumes.html">Amazon EBS volumes</a> in the <i>Amazon EBS User Guide</i>.</p> <important> <p>We strongly recommend using only paginated requests. Unpaginated requests are susceptible to throttling and timeouts.</p> </important> <note> <p>The order of the elements in the response, including those within nested structures, might vary. Applications should not assume the elements appear in a particular order.</p> </note>

    Args:
        volume_ids: <p>The volume IDs. If not specified, then all volumes are included in the response.</p>
        include_managed_resources: <p>Indicates whether to include managed resources in the output. If this parameter is set to <code>true</code>, the output includes resources that are managed by Amazon Web Services services, even if managed resource visibility is set to hidden.</p>
        dry_run: <p>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 <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
        filters: <p>The filters.</p> <ul> <li> <p> <code>attachment.attach-time</code> - The time stamp when the attachment initiated.</p> </li> <li> <p> <code>attachment.delete-on-termination</code> - Whether the volume is deleted on instance termination.</p> </li> <li> <p> <code>attachment.device</code> - The device name specified in the block device mapping (for example, <code>/dev/sda1</code>).</p> </li> <li> <p> <code>attachment.instance-id</code> - The ID of the instance the volume is attached to.</p> </li> <li> <p> <code>attachment.status</code> - The attachment state (<code>attaching</code> | <code>attached</code> | <code>detaching</code>).</p> </li> <li> <p> <code>availability-zone</code> - The Availability Zone in which the volume was created.</p> </li> <li> <p> <code>availability-zone-id</code> - The ID of the Availability Zone in which the volume was created.</p> </li> <li> <p> <code>create-time</code> - The time stamp when the volume was created.</p> </li> <li> <p> <code>encrypted</code> - Indicates whether the volume is encrypted (<code>true</code> | <code>false</code>)</p> </li> <li> <p> <code>fast-restored</code> - Indicates whether the volume was created from a snapshot that is enabled for fast snapshot restore (<code>true</code> | <code>false</code>).</p> </li> <li> <p> <code>multi-attach-enabled</code> - Indicates whether the volume is enabled for Multi-Attach (<code>true</code> | <code>false</code>)</p> </li> <li> <p> <code>operator.managed</code> - A Boolean that indicates whether this is a managed volume.</p> </li> <li> <p> <code>operator.principal</code> - The principal that manages the volume. Only valid for managed volumes, where <code>managed</code> is <code>true</code>.</p> </li> <li> <p> <code>size</code> - The size of the volume, in GiB.</p> </li> <li> <p> <code>snapshot-id</code> - The snapshot from which the volume was created.</p> </li> <li> <p> <code>status</code> - The state of the volume (<code>creating</code> | <code>available</code> | <code>in-use</code> | <code>deleting</code> | <code>deleted</code> | <code>error</code>).</p> </li> <li> <p> <code>tag</code>:<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 <code>Owner</code> and the value <code>TeamA</code>, specify <code>tag:Owner</code> for the filter name and <code>TeamA</code> for the filter value.</p> </li> <li> <p> <code>tag-key</code> - 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.</p> </li> <li> <p> <code>volume-id</code> - The volume ID.</p> </li> <li> <p> <code>volume-type</code> - The Amazon EBS volume type (<code>gp2</code> | <code>gp3</code> | <code>io1</code> | <code>io2</code> | <code>st1</code> | <code>sc1</code>| <code>standard</code>)</p> </li> </ul>
        next_token: <p>The token returned from a previous paginated request. Pagination continues from the end of the items returned by the previous request.</p>
        max_results: <p>The maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Query-Requests.html#api-pagination">Pagination</a>.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To describe all volumes
        This example describes all of your volumes in the default region.

        >>> await client.describe_volumes()
        To describe volumes that are attached to a specific instance
        This example describes all volumes that are both attached to the instance with the ID i-1234567890abcdef0 and set to delete when the instance terminates.

        >>> await client.describe_volumes(filters=[{'Values': ['i-1234567890abcdef0'], 'Name': 'attachment.instance-id'}, {'Values': ['true'], 'Name': 'attachment.delete-on-termination'}])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.describe_volumes_request.DescribeVolumesRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.describe_volumes_result.DescribeVolumesResult"
    ]:
        import capo_ec2._operations.amazon_ec2.describe_volumes

        (
            output,
            http_response,
        ) = await capo_ec2._operations.amazon_ec2.describe_volumes.async_describe_volumes(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DescribeVolumes")
    )
    input_: capo_ec2.types.describe_volumes_request.DescribeVolumesRequest = {}
    if volume_ids is not None:
        input_["volume_ids"] = volume_ids
    if include_managed_resources is not None:
        input_["include_managed_resources"] = include_managed_resources
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if filters is not None:
        input_["filters"] = filters
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output