Tag EC2 Image Builder resources - EC2 Image Builder
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Tag EC2 Image Builder resources

Tagging your resources can be useful for filtering and tracking resource costs, or other categories. You can also control access based on tags. For more information about tag-based authorization, see Authorization based on Image Builder tags

Image Builder supports the following dynamic tags:

  • - {{imagebuilder:buildDate}}

    Resolves to the build date/time at build time.

  • - {{imagebuilder:buildVersion}}

    Resolves to a build version, which is a number that is located at the end of an Image Builder Amazon Resource Name (ARN.) For example, "arn:aws:imagebuilder:us-west-2:123456789012:component/myexample-component/2019.12.02/1" shows the build version as 1.

To help you keep track of Amazon Machine Images (AMIs) that you've distributed, Image Builder automatically adds the following tags to your output AMIs.

  • "CreatedBy":"EC2 Image Builder"

  • "Ec2ImageBuilderArn":"arn:aws:imagebuilder:us-west-2:123456789012:image/simple-recipe-linux/1.0.0/10". This tag contains the ARN of the Image Builder image resource that was used to create the AMI.

Tag a resource (Amazon CLI)

The following example shows how to use an imagebuilder CLI command to to add and tag a resource in EC2 Image Builder. You must provide the resourceArn and the tags to apply to it.

The example tag-resource.json contents are as follows:

{ "resourceArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/my-example-pipeline", "tags": { "KeyName": "KeyValue" } }

Run the following command, which references the preceding tag-resource.json file.

aws imagebuilder tag-resource --cli-input-json file://tag-resource.json

Untag a resource (Amazon CLI)

The following example shows how to use an imagebuilder CLI command to remove a tag from a resource. You must provide the resourceArn and the keys to remove the tag.

The example untag-resource.json contents are as follows:

{ "resourceArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/my-example-pipeline", "tagKeys": [ "KeyName" ] }

Run the following command, which references the preceding untag-resource.json file.

aws imagebuilder untag-resource --cli-input-json file://untag-resource.json

List all of the tags for a specific resource (Amazon CLI)

The following example shows how to use an imagebuilder CLI command to list all the tags for a specific resource.

aws imagebuilder list-tags-for-resource --resource-arn arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/my-example-pipeline