:doc:`ElastiCache <../../elasticache>` / Client / add_tags_to_resource

********************
add_tags_to_resource
********************



.. py:method:: ElastiCache.Client.add_tags_to_resource(**kwargs)

  

  A tag is a key-value pair where the key and value are case-sensitive. You can use tags to categorize and track all your ElastiCache resources, with the exception of global replication group. When you add or remove tags on replication groups, those actions will be replicated to all nodes in the replication group. For more information, see `Resource-level permissions <http://docs.aws.amazon.com/AmazonElastiCache/latest/dg/IAM.ResourceLevelPermissions.html>`__.

   

  For example, you can use cost-allocation tags to your ElastiCache resources, Amazon generates a cost allocation report as a comma-separated value (CSV) file with your usage and costs aggregated by your tags. You can apply tags that represent business categories (such as cost centers, application names, or owners) to organize your costs across multiple services.

   

  For more information, see `Using Cost Allocation Tags in Amazon ElastiCache <https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/Tagging.html>`__ in the *ElastiCache User Guide*.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/elasticache-2015-02-02/AddTagsToResource>`_  


  **Request Syntax**
  ::

    response = client.add_tags_to_resource(
        ResourceName='string',
        Tags=[
            {
                'Key': 'string',
                'Value': 'string'
            },
        ]
    )
    
  :type ResourceName: string
  :param ResourceName: **[REQUIRED]** 

    The Amazon Resource Name (ARN) of the resource to which the tags are to be added, for example ``arn:aws:elasticache:us-west-2:0123456789:cluster:myCluster`` or ``arn:aws:elasticache:us-west-2:0123456789:snapshot:mySnapshot``. ElastiCache resources are *cluster* and *snapshot*.

     

    For more information about ARNs, see `Amazon Resource Names (ARNs) and Amazon Service Namespaces <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html>`__.

    

  
  :type Tags: list
  :param Tags: **[REQUIRED]** 

    A list of tags to be added to this resource. A tag is a key-value pair. A tag key must be accompanied by a tag value, although null is accepted.

    

  
    - *(dict) --* 

      A tag that can be added to an ElastiCache cluster or replication group. Tags are composed of a Key/Value pair. You can use tags to categorize and track all your ElastiCache resources, with the exception of global replication group. When you add or remove tags on replication groups, those actions will be replicated to all nodes in the replication group. A tag with a null Value is permitted.

      

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

        The key for the tag. May not be null.

        

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

        The tag's value. May be null.

        

      
    

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

    
    ::

      {
          'TagList': [
              {
                  'Key': 'string',
                  'Value': 'string'
              },
          ]
      }
      
    **Response Structure**

    

    - *(dict) --* 

      Represents the output from the ``AddTagsToResource``, ``ListTagsForResource``, and ``RemoveTagsFromResource`` operations.

      
      

      - **TagList** *(list) --* 

        A list of tags as key-value pairs.

        
        

        - *(dict) --* 

          A tag that can be added to an ElastiCache cluster or replication group. Tags are composed of a Key/Value pair. You can use tags to categorize and track all your ElastiCache resources, with the exception of global replication group. When you add or remove tags on replication groups, those actions will be replicated to all nodes in the replication group. A tag with a null Value is permitted.

          
          

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

            The key for the tag. May not be null.

            
          

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

            The tag's value. May be null.

            
      
    
  
  **Exceptions**
  
  *   :py:class:`ElastiCache.Client.exceptions.CacheClusterNotFoundFault`

  
  *   :py:class:`ElastiCache.Client.exceptions.CacheParameterGroupNotFoundFault`

  
  *   :py:class:`ElastiCache.Client.exceptions.CacheSecurityGroupNotFoundFault`

  
  *   :py:class:`ElastiCache.Client.exceptions.CacheSubnetGroupNotFoundFault`

  
  *   :py:class:`ElastiCache.Client.exceptions.InvalidReplicationGroupStateFault`

  
  *   :py:class:`ElastiCache.Client.exceptions.ReplicationGroupNotFoundFault`

  
  *   :py:class:`ElastiCache.Client.exceptions.ReservedCacheNodeNotFoundFault`

  
  *   :py:class:`ElastiCache.Client.exceptions.SnapshotNotFoundFault`

  
  *   :py:class:`ElastiCache.Client.exceptions.UserNotFoundFault`

  
  *   :py:class:`ElastiCache.Client.exceptions.UserGroupNotFoundFault`

  
  *   :py:class:`ElastiCache.Client.exceptions.ServerlessCacheNotFoundFault`

  
  *   :py:class:`ElastiCache.Client.exceptions.InvalidServerlessCacheStateFault`

  
  *   :py:class:`ElastiCache.Client.exceptions.ServerlessCacheSnapshotNotFoundFault`

  
  *   :py:class:`ElastiCache.Client.exceptions.InvalidServerlessCacheSnapshotStateFault`

  
  *   :py:class:`ElastiCache.Client.exceptions.TagQuotaPerResourceExceeded`

  
  *   :py:class:`ElastiCache.Client.exceptions.InvalidARNFault`

  

  **Examples**

  Adds up to 10 tags, key/value pairs, to a cluster or snapshot resource.
  ::

    response = client.add_tags_to_resource(
        ResourceName='arn:aws:elasticache:us-east-1:1234567890:cluster:my-mem-cluster',
        Tags=[
            {
                'Key': 'APIVersion',
                'Value': '20150202',
            },
            {
                'Key': 'Service',
                'Value': 'ElastiCache',
            },
        ],
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'TagList': [
            {
                'Key': 'APIVersion',
                'Value': '20150202',
            },
            {
                'Key': 'Service',
                'Value': 'ElastiCache',
            },
        ],
        'ResponseMetadata': {
            '...': '...',
        },
    }

  