Skip to content

describe_tags async

describe_tags(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    dry_run: Optional[Boolean] = None,
    filters: Optional[FilterList] = None,
    max_results: Optional[Integer] = None,
    next_token: Optional[String] = None,
) -> DescribeTagsResult

Describes the specified tags for your EC2 resources.

For more information about tags, see Tag your Amazon EC2 resources in the Amazon Elastic Compute Cloud 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:

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

    • key - The tag key.

    • resource-id - The ID of the resource.

    • resource-type - The resource type. For a list of possible values, see TagSpecification.

    • tag: - The key/value combination of the tag. For example, specify "tag:Owner" for the filter name and "TeamA" for the filter value to find resources with the tag "Owner=TeamA".

    • value - The tag value.

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

    The maximum number of items to return for this request. This value can be between 5 and 1000. To get the next page of items, make another request with the token returned in the output. For more information, see Pagination.

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

Raises:

Examples:

To describe the tags for a single resource This example describes the tags for the specified instance.

>>> await client.describe_tags(filters=[{'Name': 'resource-id', 'Values': ['i-1234567890abcdef8']}])
Source code in docs_src/capo_ec2/_services/async_ec2.py
async def describe_tags(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    filters: Optional["capo_ec2.types.filter_list.FilterList"] = None,
    max_results: Optional["capo_ec2.types.integer.Integer"] = None,
    next_token: Optional["capo_ec2.types.string.String"] = None,
) -> "capo_ec2.types.describe_tags_result.DescribeTagsResult":
    """<p>Describes the specified tags for your EC2 resources.</p> <p>For more information about tags, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html">Tag your Amazon EC2 resources</a> in the <i>Amazon Elastic Compute Cloud 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:
        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>key</code> - The tag key.</p> </li> <li> <p> <code>resource-id</code> - The ID of the resource.</p> </li> <li> <p> <code>resource-type</code> - The resource type. For a list of possible values, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_TagSpecification.html">TagSpecification</a>.</p> </li> <li> <p> <code>tag</code>:<key> - The key/value combination of the tag. For example, specify "tag:Owner" for the filter name and "TeamA" for the filter value to find resources with the tag "Owner=TeamA".</p> </li> <li> <p> <code>value</code> - The tag value.</p> </li> </ul>
        max_results: <p>The maximum number of items to return for this request. This value can be between 5 and 1000. 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>
        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>

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

    Examples:
        To describe the tags for a single resource
        This example describes the tags for the specified instance.

        >>> await client.describe_tags(filters=[{'Name': 'resource-id', 'Values': ['i-1234567890abcdef8']}])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.describe_tags_request.DescribeTagsRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.describe_tags_result.DescribeTagsResult"
    ]:
        import capo_ec2._operations.amazon_ec2.describe_tags

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DescribeTags")
    )
    input_: capo_ec2.types.describe_tags_request.DescribeTagsRequest = {}
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if filters is not None:
        input_["filters"] = filters
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token

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