

# Tagging resources in Lex V2
<a name="tagging"></a>

To help you manage your Amazon Lex V2 bots and bot aliases, you can assign metadata to each resource as *tags*. A tag is a label that you assign to an AWS resource. Each tag consists of a key and a value. 

Tags enable you to categorize your AWS resources in different ways, for example, by purpose, owner, or application. Tags help you to:
+ Identify and organize your AWS resources. Many AWS resources support tagging, so you can assign the same tag to resources in different services to indicate that the resources are the same. For example, you can tag a bot and the Lambda functions that it uses with the same tag.
+ Allocate costs. You activate tags on the AWS Billing and Cost Management dashboard. AWS uses the tags to categorize your costs and deliver a monthly cost allocation report to you. For Amazon Lex V2, you can allocate costs for each alias using tags specific to the alias. For more information, see [Use cost allocation tags](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html) in the *AWS Billing and Cost Management User Guide*.
+ Control access to your resources. You can use tags with Amazon Lex V2 to create policies to control access to Amazon Lex V2 resources These policies can be attached to an IAM role or user to enable tag-based access control.

You can work with tags using the AWS Management Console, the AWS Command Line Interface, or the Amazon Lex V2 API.

## Tagging your resources with the console or API
<a name="tagging-resources"></a>

If you are using the Amazon Lex V2 console, you can tag resources when you create them, or you can add the tags later. You can also use the console to update or remove existing tags.

If you are using the AWS CLI or Amazon Lex V2 API, you use the following operations to manage tags for your resource:
+ [CreateBot](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateBot.html) and [CreateBotAlias](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateBotAlias.html) – apply tags when you create a bot or a bot alias.
+ [ListTagsForResource](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_ListTagsForResource.html) – view the tags associated with a resource.
+ [TagResource](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_TagResource.html) – add and modify tags on an existing resource.
+ [UntagResource](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_UntagResource.html) – remove tags from a resource.

The following resources in Amazon Lex V2 support tagging:
+ Bots – use an Amazon Resource Name (ARN) like the following:
  + `arn:aws:lex:${Region}:${account}:bot/${bot-id}`
+ Bot aliases – use an ARN like the following:
  + `arn:aws:lex:${Region}:${account}:bot-alias/${bot-id}/${bot-alias-id}`

The `bot-id` and `bot-alias-id` values are capitalized alphanumeric strings 10 characters long.

## Tag restrictions when using Lex V2
<a name="tagging-restrictions"></a>

The following basic restrictions apply to tags on Amazon Lex V2 resources:
+ Maximum number of keys – 50 using the console, 200 using the API
+ Maximum key length – 128 characters
+ Maximum value length – 256 characters
+ Valid characters for key and value – a-z, A-Z, 0-9, space, and the following characters: \$1.:/=\$1- and @
+ Keys and values are case-sensitive
+ Don't use `aws:` as a prefix for keys, it's reserved for AWS use

# Tagging resources (console)
<a name="tags-console"></a>

You can use the console to manage tags on a bot or bot alias. You can add tags when you create the resource, or you can add, modify, or remove tags from existing resources.

**To add a tag when you create a bot**

1. Sign in to the AWS Management Console and open the Amazon Lex console at [https://console.aws.amazon.com/lex/](https://console.aws.amazon.com/lex/).

1. Choose **Create bot**.

1. In the **Advanced settings** section of **Configure bot settings**, choose ** Add new tag**. You can add tags to the bot and to the `TestBotAlias` alias.

1. Choose **Next** to continue creating your bot.

**To add a tag when you create a bot alias**

1. Sign in to the AWS Management Console and open the Amazon Lex console at [https://console.aws.amazon.com/lex/](https://console.aws.amazon.com/lex/).

1. Choose the bot that you want to add the bot alias to.

1. From the left menu, choose **Aliases** and then choose **Create alias**.

1. In **General info**, choose **Add new tag** from **Tags.**

1. Choose **Create**.

**To add, remove, or modify a tag on an existing bot**

1. Sign in to the AWS Management Console and open the Amazon Lex console at [https://console.aws.amazon.com/lex/](https://console.aws.amazon.com/lex/).

1. Choose the bot that you want to modify.

1. From the left menu, choose **Settings**, and then choose **Edit**.

1. In **Tags**, make your changes.

1. Choose **Save** to save your changes to the bot.

**To add, remove, or modify a tag on an existing alias**

1. Sign in to the AWS Management Console and open the Amazon Lex console at [https://console.aws.amazon.com/lex/](https://console.aws.amazon.com/lex/).

1. Choose the bot that you want to modify.

1. From the left menu, choose **Aliases** and then from the list of aliases, choose the alias to modify.

1. From **Alias details**, in **Tags**, choose **Modify tags**.

1. In **Manage tags**, make your changes.

1. Choose **Save** to save your changes to the alias.