Menu
Resource Groups Tagging API
API Reference (API Version 2017-01-26)

TagResources

Applies one or more tags to the specified resources. Note the following:

  • Not all resources can have tags. For a list of resources that support tagging, see Supported Resources in the AWS Resource Groups and Tag Editor User Guide.

  • Each resource can have up to 50 tags. For other limits, see Tag Restrictions in the Amazon EC2 User Guide for Linux Instances.

  • You can only tag resources that are located in the specified region for the AWS account.

  • To add tags to a resource, you need the necessary permissions for the service that the resource belongs to as well as permissions for adding tags. For more information, see Obtaining Permissions for Tagging in the AWS Resource Groups and Tag Editor User Guide.

Request Syntax

{ "ResourceARNList": [ "string" ], "Tags": { "string" : "string" } }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

ResourceARNList

A list of ARNs. An ARN (Amazon Resource Name) uniquely identifies a resource. You can specify a minimum of 1 and a maximum of 20 ARNs (resources) to tag. An ARN can be set to a maximum of 1600 characters. For more information, see Amazon Resource Names (ARNs) and AWS Service Namespaces in the AWS General Reference.

Type: Array of strings

Array Members: Minimum number of 1 item. Maximum number of 20 items.

Length Constraints: Minimum length of 1. Maximum length of 1600.

Required: Yes

Tags

The tags that you want to add to the specified resources. A tag consists of a key and a value that you define.

Type: String to string map

Key Length Constraints: Minimum length of 1. Maximum length of 128.

Value Length Constraints: Minimum length of 0. Maximum length of 256.

Required: Yes

Response Syntax

{ "FailedResourcesMap": { "string" : { "ErrorCode": "string", "ErrorMessage": "string", "StatusCode": number } } }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

FailedResourcesMap

Details of resources that could not be tagged. An error code, status code, and error message are returned for each failed item.

Type: String to FailureInfo object map

Key Length Constraints: Minimum length of 1. Maximum length of 1600.

Errors

For information about the errors that are common to all actions, see Common Errors.

InternalServiceException

The request processing failed because of an unknown error, exception, or failure. You can retry the request.

HTTP Status Code: 500

InvalidParameterException

A parameter is missing or a malformed string or invalid or out-of-range value was supplied for the request parameter.

HTTP Status Code: 400

ThrottledException

The request was denied to limit the frequency of submitted requests.

HTTP Status Code: 400

Example

Sample Request

POST / HTTP/1.1 Host: tagging.us-west-2.amazonaws.com Accept-Encoding: identity Content-Length: 82 X-Amz-Target: ResourceGroupsTaggingAPI_20170126.TagResources X-Amz-Date: 20170421T214834Z User-Agent: aws-cli/1.11.79 Python/2.7.9 Windows/7 botocore/1.5.42 Content-Type: application/x-amz-json-1.1 Authorization: AUTHPARAMS { "ResourceARNList": [ "arn:aws:s3:::example_bucket" ], "Tags": { "key": "Example_key" } }

Sample Response

HTTP/1.1 200 OK x-amzn-RequestId: 45352206-26dc-11e7-8812-6fb02084e31d Content-Type: application/x-amz-json-1.1 Content-Length: 25 Date: Fri, 21 Apr 2017 21:48:35 GMT { "FailedResourcesMap": {} }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: