TagResourceCommand

Assigns one or more tags (key-value pairs) to the specified Amazon Location Service resource.

Tags can help you organize and categorize your resources. You can also use them to scope user permissions, by granting a user permission to access or change only resources with certain tag values.

You can use the TagResource operation with an Amazon Location Service resource that already has tags. If you specify a new tag key for the resource, this tag is appended to the tags already associated with the resource. If you specify a tag key that's already associated with the resource, the new tag value that you specify replaces the previous value for that tag.

You can associate up to 50 tags with a resource.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { LocationClient, TagResourceCommand } from "@aws-sdk/client-location"; // ES Modules import
// const { LocationClient, TagResourceCommand } = require("@aws-sdk/client-location"); // CommonJS import
const client = new LocationClient(config);
const input = { // TagResourceRequest
  ResourceArn: "STRING_VALUE", // required
  Tags: { // TagMap // required
    "<keys>": "STRING_VALUE",
  },
};
const command = new TagResourceCommand(input);
const response = await client.send(command);
// {};

TagResourceCommand Input

See TagResourceCommandInput for more details

Parameter
Type
Description
ResourceArn
Required
string | undefined

The Amazon Resource Name (ARN) of the resource whose tags you want to update.

  • Format example: arn:aws:geo:region:account-id:resourcetype/ExampleResource

Tags
Required
Record<string, string> | undefined

Applies one or more tags to specific resource. A tag is a key-value pair that helps you manage, identify, search, and filter your resources.

Format: "key" : "value"

Restrictions:

  • Maximum 50 tags per resource.

  • Each tag key must be unique and must have exactly one associated value.

  • Maximum key length: 128 Unicode characters in UTF-8.

  • Maximum value length: 256 Unicode characters in UTF-8.

  • Can use alphanumeric characters (A–Z, a–z, 0–9), and the following characters: + - = . _ : /

  • Cannot use "aws:" as a prefix for a key.

TagResourceCommand Output

See TagResourceCommandOutput for details

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.

Throws

Name
Fault
Details
AccessDeniedException
client

The request was denied because of insufficient access or permissions. Check with an administrator to verify your permissions.

InternalServerException
server

The request has failed to process because of an unknown server error, exception, or failure.

ResourceNotFoundException
client

The resource that you've entered was not found in your AWS account.

ThrottlingException
client

The request was denied because of request throttling.

ValidationException
client

The input failed to meet the constraints specified by the AWS service.

LocationServiceException
Base exception class for all service exceptions from Location service.