Sub topic 9
Breaking down spend by tag
This chapter assumes you know what Cost Explorer reports look like, how grouping and filtering work, and that you have already activated cost allocation tags. Here you use those tags to attribute spend to projects, teams, or environments.
How a tag reaches a report
A tag on a resource does not appear in Cost Explorer on its own. The tag key must be activated as a cost allocation tag. Cost Explorer then applies it to usage from that point on.
Two points follow from this flow:
- Activation is not retroactive in the way many people expect. Spend from before activation is not attributed to the tag. Activation can take up to 24 hours to take effect.
- Only activated keys are offered in the Tag group-by and filter lists.
Group by a tag
In the console, open Cost Explorer, choose a time range and granularity, then set Group by to Tag and pick a key such as Project. Each value of the tag becomes a series in the chart and a row in the table.
The same query from the CLI:
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=ProjectThe End date is exclusive, so this covers all of October 2026. Group keys come back in the form Project$checkout. Spend with no Project tag comes back in a group with an empty value (Project$). That group is your untagged spend, which the next chapters examine.
Filter by a tag
Grouping splits the total. Filtering narrows it. Use a filter when you want a single slice, such as production compute. In the console, add a Tag filter and select the key and values. In the CLI, save an expression to filter.json:
{
"And": [
{ "Dimensions": { "Key": "SERVICE", "Values": ["Amazon Elastic Compute Cloud - Compute"] } },
{ "Tags": { "Key": "Environment", "Values": ["prod"] } }
]
}Then pass it with --filter file://filter.json. You can combine a filter on one key with a group-by on another. For example, filter to Environment=prod and group by Project to see which projects cost the most in production.
Common errors
- The tag key is missing from the list. The key is not activated, or fewer than 24 hours have passed. Check with
aws ce list-cost-allocation-tags --status Active. - Totals do not match. Tag-grouped values add up to the total only if you include the empty-value group. Not all charges can carry tags, so some spend stays untagged.
- Inconsistent values.
prod,Prodandproductionappear as three separate groups. Tag values are case sensitive. - Old spend shows as untagged. Usage before activation was not tagged for cost purposes.
- Member account cannot activate tags. In an organization, activation is done from the management account.
Exercise
Your Project tag is activated, but a query grouped by Project shows 40% of October spend in a group with an empty value. What does this group contain, and what is the first thing you check?
Show answer
It contains spend with no Project tag, either because resources were never tagged, the service does not support tags for that charge, or the usage happened before activation. First check which services make up that group by adding a filter on the empty tag value and grouping by SERVICE.