:doc:`EC2 <../../ec2>` / Client / describe_tags

*************
describe_tags
*************



.. py:method:: EC2.Client.describe_tags(**kwargs)

  

  Describes the specified tags for your EC2 resources.

   

  For more information about tags, see `Tag your Amazon EC2 resources <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html>`__ in the *Amazon Elastic Compute Cloud User Guide*.

   

  .. warning::

     

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

     

   

  .. note::

    

    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.

    

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/DescribeTags>`_  


  **Request Syntax**
  ::

    response = client.describe_tags(
        DryRun=True|False,
        Filters=[
            {
                'Name': 'string',
                'Values': [
                    'string',
                ]
            },
        ],
        MaxResults=123,
        NextToken='string'
    )
    
  :type DryRun: boolean
  :param DryRun: 

    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 Filters: list
  :param Filters: 

    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 <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_TagSpecification.html>`__.
     
    * ``tag``:<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".
     
    * ``value`` - The tag value.
    

    

  
    - *(dict) --* 

      A filter name and value pair that is used to return a more specific list of results from a describe operation. Filters can be used to match a set of resources by specific criteria, such as tags, attributes, or IDs.

       

      If you specify multiple filters, the filters are joined with an ``AND``, and the request returns only results that match all of the specified filters.

       

      For more information, see `List and filter using the CLI and API <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Filtering.html#Filtering_Resources_CLI>`__ in the *Amazon EC2 User Guide*.

      

    
      - **Name** *(string) --* 

        The name of the filter. Filter names are case-sensitive.

        

      
      - **Values** *(list) --* 

        The filter values. Filter values are case-sensitive. If you specify multiple values for a filter, the values are joined with an ``OR``, and the request returns all results that match any of the specified values.

        

      
        - *(string) --* 

        
    
    

  :type MaxResults: integer
  :param MaxResults: 

    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 <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Query-Requests.html#api-pagination>`__.

    

  
  :type NextToken: string
  :param NextToken: 

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

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'NextToken': 'string',
          'Tags': [
              {
                  'Key': 'string',
                  'ResourceId': 'string',
                  'ResourceType': 'capacity-reservation'|'client-vpn-endpoint'|'customer-gateway'|'carrier-gateway'|'coip-pool'|'declarative-policies-report'|'dedicated-host'|'dhcp-options'|'egress-only-internet-gateway'|'elastic-ip'|'elastic-gpu'|'export-image-task'|'export-instance-task'|'fleet'|'fpga-image'|'host-reservation'|'image'|'image-usage-report'|'import-image-task'|'import-snapshot-task'|'instance'|'instance-event-window'|'internet-gateway'|'ipam'|'ipam-pool'|'ipam-scope'|'ipv4pool-ec2'|'ipv6pool-ec2'|'key-pair'|'launch-template'|'local-gateway'|'local-gateway-route-table'|'local-gateway-virtual-interface'|'local-gateway-virtual-interface-group'|'local-gateway-route-table-vpc-association'|'local-gateway-route-table-virtual-interface-group-association'|'natgateway'|'network-acl'|'network-interface'|'network-insights-analysis'|'network-insights-path'|'network-insights-access-scope'|'network-insights-access-scope-analysis'|'outpost-lag'|'placement-group'|'prefix-list'|'replace-root-volume-task'|'reserved-instances'|'route-table'|'security-group'|'security-group-rule'|'service-link-virtual-interface'|'snapshot'|'spot-fleet-request'|'spot-instances-request'|'subnet'|'subnet-cidr-reservation'|'traffic-mirror-filter'|'traffic-mirror-session'|'traffic-mirror-target'|'transit-gateway'|'transit-gateway-attachment'|'transit-gateway-connect-peer'|'transit-gateway-multicast-domain'|'transit-gateway-policy-table'|'transit-gateway-metering-policy'|'transit-gateway-route-table'|'transit-gateway-route-table-announcement'|'volume'|'vpc'|'vpc-endpoint'|'vpc-endpoint-connection'|'vpc-endpoint-service'|'vpc-endpoint-service-permission'|'vpc-peering-connection'|'vpn-connection'|'vpn-gateway'|'vpc-flow-log'|'capacity-reservation-fleet'|'traffic-mirror-filter-rule'|'vpc-endpoint-connection-device-type'|'verified-access-instance'|'verified-access-group'|'verified-access-endpoint'|'verified-access-policy'|'verified-access-trust-provider'|'vpn-connection-device-type'|'vpc-block-public-access-exclusion'|'vpc-encryption-control'|'route-server'|'route-server-endpoint'|'route-server-peer'|'ipam-resource-discovery'|'ipam-resource-discovery-association'|'instance-connect-endpoint'|'verified-access-endpoint-target'|'ipam-external-resource-verification-token'|'capacity-block'|'mac-modification-task'|'ipam-prefix-list-resolver'|'ipam-policy'|'ipam-prefix-list-resolver-target'|'secondary-interface'|'secondary-network'|'secondary-subnet'|'capacity-manager-data-export'|'vpn-concentrator',
                  'Value': 'string'
              },
          ]
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **NextToken** *(string) --* 

        The token to include in another request to get the next page of items. This value is ``null`` when there are no more items to return.

        
      

      - **Tags** *(list) --* 

        The tags.

        
        

        - *(dict) --* 

          Describes a tag.

          
          

          - **Key** *(string) --* 

            The tag key.

            
          

          - **ResourceId** *(string) --* 

            The ID of the resource.

            
          

          - **ResourceType** *(string) --* 

            The resource type.

            
          

          - **Value** *(string) --* 

            The tag value.

            
      
    
  

  **Examples**

  This example describes the tags for the specified instance.
  ::

    response = client.describe_tags(
        Filters=[
            {
                'Name': 'resource-id',
                'Values': [
                    'i-1234567890abcdef8',
                ],
            },
        ],
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'Tags': [
            {
                'Key': 'Stack',
                'ResourceId': 'i-1234567890abcdef8',
                'ResourceType': 'instance',
                'Value': 'test',
            },
            {
                'Key': 'Name',
                'ResourceId': 'i-1234567890abcdef8',
                'ResourceType': 'instance',
                'Value': 'Beta Server',
            },
        ],
        'ResponseMetadata': {
            '...': '...',
        },
    }

  