Sub topic 7
AWS-generated and user-defined tags
This chapter assumes you know what a resource tag is (a key and value pair on a resource) and that you can use the AWS Management Console and, optionally, the AWS CLI. It covers the two kinds of cost allocation tags and how they differ in practice.
Two kinds of cost allocation tags
Cost Explorer can group spend by a tag only if the tag key is a cost allocation tag. There are two types:
- User-defined tags are keys you create, such as
ProjectorEnvironment. You apply them to resources yourself, or through automation. - AWS-generated tags are keys that AWS creates and applies for you. They always start with the prefix
aws:. The best known isaws:createdBy, which records which identity created a resource.
| Property | User-defined | AWS-generated |
|---|---|---|
| Key prefix | Anything except `aws:` | `aws:` |
| Who applies it | You | AWS |
| Can you edit or delete it | Yes | No |
| Appears in billing tools | After activation | After activation |
| Counts toward the per-resource tag limit | Yes | No |
The aws: prefix is reserved. You cannot create, edit or delete a tag whose key starts with it, so a tag you can modify is always a user-defined one.
What AWS-generated tags give you
An AWS-generated tag such as aws:createdBy can attribute spend without any tagging effort from your teams. It is a useful fallback when resources were created before you had a tagging convention. Its coverage is limited, though. AWS applies it only to supported resource types, and it only records who created a resource. It cannot tell you which project or cost centre the resource belongs to.
For that reason, treat AWS-generated tags as a supplement. Business meaning, such as project, team and environment, must come from user-defined tags.
Both kinds need activation
Applying a tag to a resource does not make it available in cost reports. Each key must be activated as a cost allocation tag, and this applies to both types. In an organization, activation is done from the management account.
aws ec2 create-tags \
--resources i-0123456789abcdef0 \
--tags Key=Project,Value=checkout Key=Environment,Value=prodThis adds two user-defined tags to an EC2 instance. They do nothing for reporting until the keys are activated, which the next chapter covers.
You can check which keys are already active:
aws ce list-cost-allocation-tags --status ActiveThe output lists each active key with its Type, either UserDefined or AWSGenerated. Use this field to see which kind each key is.
flowchart TDCommon errors
- Expecting a tag to show up immediately. Activated keys can take up to 24 hours to appear in Cost Explorer.
- Expecting history. Tag data is recorded from the time of activation onward. Spend before that date is not retroactively grouped by the tag.
- Case mismatches. Tag keys and values are case sensitive.
Projectandprojectare different keys, and each needs its own activation. - Trying to create
aws:tags. The API rejects any key with that prefix.
Exercise
A teammate finds that aws:createdBy is active but cannot attribute spend to the checkout project. Why, and what should they add?
Show answer
aws:createdBy only records which identity created a resource, not which project it serves. They should apply a user-defined tag such as Project=checkout to the resources and activate the Project key as a cost allocation tag.
Exercise
You run aws ce list-cost-allocation-tags --status Active. Which field in the output tells you whether a key is user-defined or AWS-generated?
Show answer
The Type field, which is UserDefined or AWSGenerated.