tag_resource
(**kwargs)¶Associates the specified tags to a resource with the specified resourceArn
. If existing tags on a resource aren't specified in the request parameters, they aren't changed. When a resource is deleted, the tags that are associated with that resource are deleted as well.
See also: AWS API Documentation
Request Syntax
response = client.tag_resource(
resourceArn='string',
tags=[
{
'key': 'string',
'value': 'string'
},
]
)
[REQUIRED]
The Amazon Resource Name (ARN) of the resource to add tags to. Currently, the supported resources are Amazon ECS capacity providers, tasks, services, task definitions, clusters, and container instances.
[REQUIRED]
The tags to add to the resource. A tag is an array of key-value pairs.
The following basic restrictions apply to tags:
aws:
, AWS:
, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for Amazon Web Services use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.The metadata that you apply to a resource to help you categorize and organize them. Each tag consists of a key and an optional value. You define them.
The following basic restrictions apply to tags:
aws:
, AWS:
, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for Amazon Web Services use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.One part of a key-value pair that make up a tag. A key
is a general label that acts like a category for more specific tag values.
The optional part of a key-value pair that make up a tag. A value
acts as a descriptor within a tag category (key).
dict
Response Syntax
{}
Response Structure
Exceptions
ECS.Client.exceptions.ServerException
ECS.Client.exceptions.ClientException
ECS.Client.exceptions.ClusterNotFoundException
ECS.Client.exceptions.ResourceNotFoundException
ECS.Client.exceptions.InvalidParameterException
Examples
This example tags the 'dev' cluster with key 'team' and value 'dev'.
response = client.tag_resource(
resourceArn='arn:aws:ecs:region:aws_account_id:cluster/dev',
tags=[
{
'key': 'team',
'value': 'dev',
},
],
)
print(response)
Expected Output:
{
'ResponseMetadata': {
'...': '...',
},
}