Sub topic 7
AWS-generated and user-defined tags
This chapter assumes you can use the AWS Management Console, know what AWS Organizations and a management account are, and have met the basics of tags (key-value pairs on resources). The CLI examples are optional.
Cost Explorer can group spend by tag, but only for tags that have been activated as cost allocation tags. Two families of tags can be activated: AWS-generated tags and user-defined tags. They differ in who creates them, what they cost you in effort, and how reliable they are.
The two tag families
A user-defined tag is one you or your tooling attach to a resource. You pick the key and the value, for example Project=checkout. In Billing and Cost Management, these keys are listed with the type UserDefined. In the Cost and Usage Report they appear as columns prefixed with user:.
An AWS-generated tag is one AWS attaches on your behalf. Its key always starts with aws:. The best known is aws:createdBy, which records the identity that created the resource. Services such as CloudFormation also add aws:-prefixed tags like aws:cloudformation:stack-name to the resources a stack creates. In Billing and Cost Management these keys are listed with the type AWSGenerated.
| Property | AWS-generated | User-defined |
|---|---|---|
| Key prefix | `aws:` | Anything except `aws:` |
| Who sets the value | AWS | You, a script, or a template |
| Can you edit or delete it? | No | Yes |
| Counts toward the 50-tag limit per resource? | No | Yes |
| Coverage | Only certain services and resources | Any taggable resource |
| Meaning of the value | Fixed by AWS, such as who created the resource | Whatever your convention says |
| Activation needed for cost reports? | Yes | Yes |
The aws: prefix is reserved. You cannot create a tag whose key starts with aws:, and you cannot modify one that AWS created.
How each family reaches a cost report
Neither family shows up in Cost Explorer automatically. Both pass through activation, which is the step that tells billing to copy a tag key into your cost data.
Three timing rules matter in practice:
- A new tag key can take up to 24 hours to appear in the cost allocation tag list after a resource carrying it exists.
- After you activate a key, it can take up to another 24 hours before it appears in Cost Explorer.
- Activation has historically applied only to usage from that point forward. AWS has added an option to backfill recent months for newly activated keys, so check the current documentation before promising a retroactive report.
Creating user-defined tags
The following command tags one EC2 instance with two user-defined keys.
aws ec2 create-tags \
--resources i-0123456789abcdef0 \
--tags Key=Project,Value=checkout Key=Environment,Value=prodThis tags the instance only. It does not tag the EBS volumes or network interfaces attached to it. Each of those is a separate billable resource and needs its own tags, or a tool that propagates them. Some services have an option to copy tags to child resources. Auto Scaling groups can propagate tags to the instances they launch, and ECS can propagate tags from a service or task definition to tasks. Check each service you use.
User-defined tags follow these rules:
- A key can be up to 128 characters and a value up to 256 characters.
- A resource can carry up to 50 user-defined tags.
- Keys and values are case-sensitive.
Projectandprojectare different keys. - Permitted characters are letters, numbers, spaces, and
_ . : / = + - @. - A key must be unique on a given resource. Each key has exactly one value there.
Case sensitivity is the most common source of messy reports. If one team writes Environment=prod and another writes environment=Prod, you get two keys to activate and two sets of values. Cost Explorer cannot merge them. Cost Categories, covered in a later chapter, can map such variants to one group, but fixing the tags is cleaner.
Working with AWS-generated tags
You cannot add an AWS-generated tag. You can only activate one that AWS has already created.
List the AWS-generated keys that are available in your account:
aws ce list-cost-allocation-tags --type AWSGeneratedThen activate aws:createdBy:
aws ce update-cost-allocation-tags-status \
--cost-allocation-tags-status TagKey=aws:createdBy,Status=ActiveConfirm which keys are active, from both families:
aws ce list-cost-allocation-tags --status ActiveEach entry in the output has a TagKey, a Type (AWSGenerated or UserDefined), a Status (Active or Inactive), and a last-updated date. Check the Type field when you audit your configuration, because a key like aws:createdBy is easy to overlook among your own keys.
What aws:createdBy tells you
The value of aws:createdBy identifies the principal that created the resource. For an IAM user it has the form IAMUser:AIDAEXAMPLEID:alice, and for the root user it has the form Root:111122223333. This is useful for a question such as "who launched the instances that cost the most last week?". It also has limits:
- It is applied only to resources created after the tag was activated. Older resources do not get it.
- It is added only by some services and for some resource types. A resource of an unsupported type simply has no value.
- It records the creator, not the owner. A pipeline role that creates every resource produces one value for all of them, which says nothing about which team owns the spend.
Treat aws:createdBy as a way to investigate, not a replacement for ownership tags that you control.
Activation permissions
Cost allocation tags are activated from the management account of an organization, or from a standalone account. Member accounts cannot activate them in an organization. The caller needs permission for ce:UpdateCostAllocationTagsStatus to activate or deactivate keys, and ce:ListCostAllocationTags to list them. Once a management account activates a key, the key applies to every account in the organization, so member accounts can use it in their own Cost Explorer views.
Grouping by each family in the CLI
Once active, both kinds of key are used the same way in a query. The key is the tag name, with the aws: prefix kept for generated tags.
aws ce get-cost-and-usage \
--time-period Start=2026-10-01,End=2026-11-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=TAG,Key=ProjectSpend on resources with no Project tag is returned in a group whose tag value is empty. Its size is a quick measure of how much spend your tagging does not cover. Replacing Key=Project with Key=aws:createdBy gives the same breakdown by creator.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Tag key missing from the activation list | No resource with that key exists yet, or less than 24 hours have passed | Confirm the resource has the tag, then wait and refresh |
| Key is active but Cost Explorer shows only untagged spend | Fewer than 24 hours since activation, or the usage predates activation | Wait, and check whether a backfill is available |
| Activation fails or the option is greyed out | You are signed in to a member account | Use the management account |
| Same project appears under two groups | Inconsistent case or spelling of keys or values | Standardize the tags, or map them with Cost Categories |
| `aws:createdBy` is empty for old resources | The tag is applied only to resources created after activation | Rely on a user-defined owner tag for older resources |
| Child resources show no tag | Tags were applied to the parent only | Tag the volumes and interfaces, or use tag propagation |
Choosing between them
Use user-defined tags for anything that carries business meaning: project, team, environment, cost center, and owner. You control the values, so you can make them match how your organization reports spend. Use aws:createdBy and the CloudFormation tags as a supplement. They help you trace where untagged resources came from and which stack produced a cost, which feeds directly into the work of finding untagged spend later in this tutorial.
Exercise
A finance analyst asks you to report spend per team, and you see that aws:createdBy is already active. Why is it not enough on its own, and which command would you run to check which active keys are user-defined?
Show answer
aws:createdBy records which identity created a resource, not which team owns the spend, and it is missing for resources created before activation or by services that do not support it. You need a user-defined ownership tag such as Team, activated as a cost allocation tag. To check the active user-defined keys, run aws ce list-cost-allocation-tags --status Active --type UserDefined, or list all active keys and read the Type field in each entry.
Exercise
You tag an EC2 instance with Project=checkout and activate the Project key. The next day a Cost Explorer report grouped by Project shows the instance's EBS volume under an empty tag value. Why, and what are two fixes?
Show answer
Tags on an instance do not automatically apply to its attached EBS volumes, which are separate billable resources. Fix it by tagging the volumes directly (for example with aws ec2 create-tags on the volume IDs), or by using a service feature or tooling that copies tags to child resources when they are created.