AWS Elastic Beanstalk
Developer Guide (API Version 2010-12-01)
AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Tagging Resources in Your Elastic Beanstalk Environment

Introduction to Environment Tagging

AWS Elastic Beanstalk provides support for specifying tags to apply to resources in your environment. Tags are key-value pairs. They help you identify environments in cost allocation reports. This is especially useful if you manage many environments. You can also use tags to manage permissions at the resource level.

By default, Elastic Beanstalk applies three tags:

  • elasticbeanstalk:environment-name is the name of the environment. elasticbeanstalk:environment-id is the environment ID.

  • elasticbeanstalk:environment-id is the environment ID.

  • Name is also the name of the environment. Name is used in the Amazon EC2 dashboard to identify and sort resources.

You can't edit these default tags.

You can specify tags when you create the Elastic Beanstalk environment. In an existing environment, you can add or remove tags, and you can update the values of existing tags. In addition to the default tags, you can add up to 47 additional tags to each environment.

Constraints

  • Keys and values can contain letters, numbers, white space, and the following symbols: _ . : / = + - @

  • Keys can contain up to 128 characters. Values can contain up to 256 characters.

  • Keys are case-sensitive.

  • Keys cannot begin with aws: or elasticbeanstalk:.

  • Values cannot match the environment name.

You can use cost allocation reports to track your usage of AWS resources. The reports include both tagged and untagged resources, but they aggregate costs according to tags. For information about how cost allocation reports use tags, see Use Cost Allocation Tags for Custom Billing Reports in the AWS Billing and Cost Management User Guide.

Adding Tags During Environment Creation

When you use the AWS Management Console to create an environment, you can specify tag keys and values on the Tags page of the Create New Environment wizard, as shown.


        tags page where you specify tag keys and values

If you use the EB CLI to create environments, use the --tags option with eb create to add tags.

~/workspace/my-app$ eb create --tags mytag1=value1,mytag2=value2

With the AWS CLI or other API-based clients, use the --tags parameter on the create-environment command.

$ aws elasticbeanstalk create-environment --tags Key=mytag1,Value=value1 Key=mytag2,Value=value2 --application-name my-app --environment-name my-env --cname-prefix my-app --version-label v1 --template-name my-saved-config

Saved configurations include user-defined tags. When you apply a saved configuration that contains tags during environment creation, those tags are applied to the new environment, as long as you don't specify any new tags. If you add tags to an environment using one of the preceding methods, any tags defined in the saved configuration are discarded.

Managing Tags of an Existing Environment

You can add, update, and delete tags in an existing Elastic Beanstalk environment. Elastic Beanstalk applies the changes to your environment's resources.

You can't edit the default tags that Elastic Beanstalk applies to your environment. For details about these default tags, see Introduction to Environment Tagging.

To manage an environment's tags in the AWS Management Console

  1. Navigate to the environment management console for your environment.

  2. In the side navigation pane, choose Tags.

    The tag management page shows the list of tags that currently exist in the environment.

    
            tag management page shows tags for the environment
  3. Add, update, or delete tags.

    • To add a tag, type it into the empty boxes at the bottom of the list.

    • To update a tag's key or value, edit the respective box in the tag's row.

    • To delete a tag, choose 
                  Remove tag
                next to the tag's value box.

  4. Choose Apply.

If you use the EB CLI to update environments, use eb tags to add, update, delete, or list tags.

For example, the following command lists the tags in your default environment.

~/workspace/my-app$ eb tags --list

The following command updates the tag mytag1 and deletes the tag mytag2.

~/workspace/my-app$ eb tags --update mytag1=newvalue --delete mytag2

For a complete list of options and more examples, see eb tags.

With the AWS CLI or other API-based clients, use the list-tags-for-resource command to list the tags of an environment.

$ aws elasticbeanstalk list-tags-for-resource --resource-arn "arn:aws:elasticbeanstalk:us-west-2:my-account-id:environment/my-app/my-env"

Use the update-tags-for-resource command to add, update, or delete tags in an environment.

$ aws elasticbeanstalk update-tags-for-resource --tags-to-add
      Key=mytag1,Value=newvalue --tags-to-remove mytag2 --resource-arn "arn:aws:elasticbeanstalk:us-west-2:my-account-id:environment/my-app/my-env"

Note

To use these two commands with an Elastic Beanstalk environment, you need the environment's ARN. You can retrieve the ARN by using the following command.

aws elasticbeanstalk describe-environments

Specify both tags to add and tags to update in the --tags-to-add parameter of update-tags-for-resource. A nonexisting tag is added, and an existing tag's value is updated.