Resource tag - AWS CloudFormation

Resource tag

You can use the Resource Tags property to apply tags to resources, which can help you identify and categorize those resources. You can tag only resources for which AWS CloudFormation supports tagging. For information about which resources you can tag with CloudFormation, see the individual resources in AWS resource and property types reference.

Note

Tagging implementations might vary by resource. For example, AWS::AutoScaling::AutoScalingGroup provides an additional, required PropagateAtLaunch property as part of its tagging scheme.

In addition to any tags you define, CloudFormation automatically creates the following stack-level tags with the prefix aws::

  • aws:cloudformation:logical-id

  • aws:cloudformation:stack-id

  • aws:cloudformation:stack-name

The aws: prefix is reserved for AWS use. This prefix is case-insensitive. If you use this prefix in the Key or Value property, you can't update or delete the tag. Tags with this prefix don't count toward the number of tags per resource.

Propagation of stack-level tags to resources, including automatically created tags, can vary by resource. For example, tags aren't propagated to Amazon EBS volumes that are created from block device mappings.

Syntax

JSON

{ "Key" : String, "Value" : String }

YAML

Key: String Value: String

Properties

Key

The key name of the tag. You can specify a value that's 1 to 128 Unicode characters in length and can't be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., :, /, =, +, @, -, and ".

Required: Yes

Type: String

Value

The value for the tag. You can specify a value that's 1 to 256 characters in length. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -.

Required: Yes

Type: String

Example

This example shows a Tags property. You specify this property within the Properties section of a resource that supports it. When the resource is created, it's tagged with the tags you declare.

JSON

"Tags" : [ { "Key" : "keyname1", "Value" : "value1" }, { "Key" : "keyname2", "Value" : "value2" } ]

YAML

Tags: - Key: "keyname1" Value: "value1" - Key: "keyname2" Value: "value2"

See also