Amazon Elastic Compute Cloud
User Guide for Linux (API Version 2014-06-15)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Tagging Your Amazon EC2 Resources

To help you manage your instances, images, and other Amazon EC2 resources, you can assign your own metadata to each resource in the form of tags. This topic describes tags and shows you how to create them.

Tag Basics

Tags enable you to categorize your AWS resources in different ways, for example, by purpose, owner, or environment. Each tag consists of a key and an optional value, both of which you define. For example, you could define a set of tags for your account's Amazon EC2 instances that helps you track each instance's owner and stack level. We recommend that you devise a set of tag keys that meets your needs for each resource type. Using a consistent set of tag keys makes it easier for you to manage your resources. You can search and filter the resources based on the tags you add.

The following diagram illustrates how tagging works. In this example, you've assigned two tags to each of your instances, one called Owner and another called Stack. Each of the tags also has an associated value.

Tag example

Tags don't have any semantic meaning to Amazon EC2 and are interpreted strictly as a string of characters. Also, tags are not automatically assigned to your resources.

You can work with tags using the AWS Management Console, the Amazon EC2 command line interface (CLI), and the Amazon EC2 API.

You can assign tags only to resources that already exist. When you use the Amazon EC2 console, you can access a list of tags to add to an instance, which will be applied immediately after the instance is created. If you add a tag that has the same key as an existing tag on that resource, the new value overwrites the old value. You can edit tag keys and values, and you can remove tags from a resource at any time. You can set a tag's value to the empty string, but you can't set a tag's value to null.

If you're using AWS Identity and Access Management (IAM), you can control which users in your AWS account have permission to create, edit, or delete tags. For more information about IAM, see Controlling Access to Amazon EC2 Resources.

Tag Restrictions

The following basic restrictions apply to tags:

  • Maximum number of tags per resource—10

  • Maximum key length—127 Unicode characters

  • Maximum value length—255 Unicode characters

  • Tag keys and values are case sensitive.

  • Do not use the aws: prefix in your tag names or values because it is reserved for AWS use. You can't edit or delete tag names or values with this prefix. Tags with this prefix do not count against your tags per resource limit.

You can't terminate, stop, or delete a resource based solely on its tags; you must specify the resource identifier. For example, to delete snapshots that you tagged with a tag key called DeleteMe, you must first get a list of those snapshots using DescribeSnapshots with a filter that specifies the tag. Then you use DeleteSnapshots with the resource identifiers of the snapshots (for example, snap-1a2b3c4d). You can't call DeleteSnapshots with a filter that specified the tag. For more information about using filters when listing your resources, see Listing and Filtering Your Resources.

You can tag public or shared resources, but the tags you assign are available only to your AWS account and not to the other accounts sharing the resource.

You can't tag all resources, and some you can only tag using API actions or the command line. The following table lists all Amazon EC2 resources and the tagging restrictions that apply to them, if any. Resources with tagging restrictions of None can be tagged with API actions, the CLI, and the console.

ResourceTagging supportTagging restrictions

AMI

Yes

None

Bundle Task

No

Customer Gateway

Yes

None

DHCP Option

Yes

None

EBS Volume

Yes

None

Instance Store Volume

No

Elastic IP

No

Instance

Yes

None

Internet Gateway

Yes

None

Key Pair

No

Load Balancer

Yes

None

Network ACL

Yes

None

Network Interface

Yes

None

Placement Group

No

Reserved Instance

Yes

None

Reserved Instance Listing

No

Route Table

Yes

None

Spot Instance Request

Yes

None

Security Group - EC2 Classic

Yes

None

Security Group - VPC

Yes

None

Snapshot

Yes

None

Subnet

Yes

None

Virtual Private Gateway

Yes

None

VPC

Yes

None

VPC Peering Connection

Yes

None

VPN Connection

Yes

None

For more information about tagging using the AWS console, see Working with Tags in the Console. For more information about tagging using the API or command line, see API and CLI Overview.

Tagging Your Resources for Billing

You can use tags to organize your AWS bill to reflect your own cost structure. To do this, sign up to get your AWS account bill with tag key values included. Then, to see the cost of your combined resources, you can organize your billing information based on resources that have the same tag key values. For example, you can tag several resources with a specific application name, and then organize your billing information to see the total cost of that application across several services. For more information, see Cost Allocation and Tagging in About AWS Account Billing.

Working with Tags in the Console

Using the Amazon EC2 console, you can see which tags are in use across all of your Amazon EC2 resources in the same region. You can view tags by resource and by resource type, and you can also view how many items of each resource type are associated with a specified tag. You can also use the Amazon EC2 console to apply or remove tags from one or more resources at a time.

Displaying Tags

You can display tags in two different ways in the Amazon EC2 console. You can display the tags for an individual resource or for all resources.

To display tags for individual resources

When you select a resource-specific page in the Amazon EC2 console, it displays a list of those resources. For example, if you select Instances from the navigation pane, the console displays a list of Amazon EC2 instances. When you select a resource from one of these lists (e.g., an instance), if the resource supports tags, you can view and manage its tags. On most resource pages, you can view the tags in the Tags tab on the details pane. The following image shows the Tags tab for an instance with two tags: Name = DNS Server and Purpose = Network Management.

You can add a column to the resource list that displays all values for tags with the same key. This column enables you to sort and filter the resource list by the tag. There are two ways to add a new column to the resource list to display your tags.

  • On the Tags tab, click Show Column for the tag.

  • Click the Show/Hide Columns gear-shaped icon, and in the Show/Hide Columns dialog box, select the tag key under Your Tag Keys.

To display tags for all resources

You can display tags across all resources by selecting Tags from the navigation pane in the Amazon EC2 console. The following image shows the Tags pane, which lists all tags in use by resource type.

The Tags pane in the Amazon EC2 console

Adding and Deleting Tags on an Individual Resource

You can manage tags for an individual resource directly from the resource's page. If you are managing an AMI's tags, the procedures are different from that of other resources. All procedures are explained below.

To add a tag to an individual resource

  1. Open the Amazon EC2 console.

  2. From the navigation bar, select the region that meets your needs. This choice is important because some Amazon EC2 resources can be shared between regions, while others can't. For more information, see Resource Locations.

    Region selector
  3. In the navigation pane, click a resource type (for example, Instances).

  4. Select the resource from the resource list.

  5. Select the Tags tab in the details pane.

  6. Click the Add/Edit Tags button.

  7. In the Add/Edit Tags dialog box, specify the key and value for each tag, and then click Save.

To delete a tag from an individual resource

  1. Open the Amazon EC2 console.

  2. From the navigation bar, select the region that meets your needs. This choice is important because some Amazon EC2 resources can be shared between regions, while others can't. For more information, see Resource Locations.

  3. In the navigation pane, click a resource type (for example, Instances).

  4. Select the resource from the resource list.

  5. Select the Tags tab in the details pane.

  6. Click Add/Edit Tags, click the Delete icon for the tag, and click Save.

Adding and Deleting Tags to a Group of Resources

To add a tag to a group of resources

  1. Open the Amazon EC2 console.

  2. From the navigation bar, select the region that meets your needs. This choice is important because some Amazon EC2 resources can be shared between regions, while others can't. For more information, see Resource Locations.

    Region selector
  3. In the navigation pane, click Tags.

  4. At the top of the content pane, click Manage Tags.

  5. From the Filter drop-down list, select the type of resource (for example, instances) that you want to add tags to.

  6. In the resources list, select the check box next to each resource that you want to add tags to.

  7. In the Key and Value boxes under Add Tag, type the tag key and values you want, and then click Add Tag.

    Note

    If you add a new tag with the same tag key as an existing tag, the new tag overwrites the existing tag.

To remove a tag from a group of resources

  1. Open the Amazon EC2 console.

  2. From the navigation bar, select the region that meets your needs. This choice is important because some Amazon EC2 resources can be shared between regions, while others can't. For more information, see Resource Locations.

  3. In the navigation pane, click Tags.

  4. At the top of the content pane, click Manage Tags.

  5. To view the tags in use, click the Show/Hide Columns gear-shaped icon, and in the Show/Hide Columns dialog box, select the tag keys you want to view, and then click Close.

  6. From the Filter drop-down list, select the type of resource (for example, instances) that you want to remove tags from.

  7. In the resource list, select the check box next to each resource that you want to remove tags from.

  8. Under Remove Tag, click in the Key box to select a key, or type its name, and then click Remove Tag.

Adding a Tag When You Launch an Instance

To add a tag using the Launch Wizard

  1. From the navigation bar, select the region for the instance. This choice is important because some Amazon EC2 resources can be shared between regions, while others can't. Select the region that meets your needs. For more information, see Resource Locations.

    Region selector
  2. Click the Launch Instance button on the EC2 dashboard.

  3. The Choose an Amazon Machine Image (AMI) page displays a list of basic configurations called Amazon Machine Images (AMIs). Choose the AMI that you want to use and click its Select button. For more information about selecting an AMI, see Finding an AMI.

  4. On the Configure Instance Details page, configure the instance settings as necessary, and then click Next: Add Storage.

  5. On the Add Storage page, you can specify additional storage volumes for your instance. Click Next: Tag Instance when done.

  6. On the Tag Instance page, specify tags for the instance by providing key and value combinations. Click Create Tag to add more than one tag to your instance. Click Next: Configure Security Group when you are done.

  7. On the Configure Security Group page, you can choose from an existing security group that you own, or let the wizard create a new security group for you. Click Review and Launch when you are done.

  8. Review your settings. When you're satisfied with your selections, click Launch. Select an existing key pair or create a new one, select the acknowledgment check box, and then click Launch Instances.

Filtering a List of Resources by Tag

You can filter your list of resources based on one or more tag keys and tag values.

To filter a list of resources by tag

  1. Display a column for the tag as follows:

    1. Select one of the resources.

    2. Select the Tags tab in the details pane.

    3. Locate the tag in the list and click Show Column.

  2. Click the filter icon in the top right corner of the column for the tag to display the filter list.

  3. Select the tag values, and then click Apply Filter to filter the results list.

    Note

    Some screens have more advanced search functionality. For more information about this see Listing and Filtering Your Resources.

API and CLI Overview

Use the following API and CLI commands to add, update, list, and delete the tags for your resources. The documentation for each command provides examples. For more information about these command line interfaces, see Accessing Amazon EC2.

DescriptionAmazon EC2 CLIAWS CLIAWS Tools for Windows PowerShellAPI Action

Adds or overwrites one or more tags for the specified resource or resources.

ec2-create-tags

create-tags

New-EC2Tag

CreateTags

Deletes the specified tags from the specified resource or resources.

ec2-delete-tags

delete-tags

Remove-EC2Tag

DeleteTags

Describes one or more tags for your resources.

ec2-describe-tags

describe-tags

Get-EC2Tag

DescribeTags

You can also filter a list of resources according to their tags. For example syntax, see Filtering Resources Using the Console. For a list of supported filters per Amazon EC2 resource, see the relevant documentation: