Tags & Resource Organization
Tags are key-value labels you attach to resources to organize, track cost and control access.
A tag is a simple key-value label you can attach to almost any AWS resource. Tags carry no meaning to AWS itself — you define what they mean — but they are essential for managing a growing account.
What tags enable
- Cost allocation — break the bill down by
Project,TeamorEnvironmentin Cost Explorer. - Automation — target resources by tag in scripts and policies (e.g. stop everything tagged
Environment=devovernight). - Access control — write IAM policies that allow actions only on resources with a matching tag.
- Organization — filter and search resources in the Console.
A good tagging strategy
Agree on a small, consistent set of keys and apply them everywhere. Common ones: Name, Environment, Project, Owner, CostCenter.
Example
# Tag an EC2 instance with several keys at once
aws ec2 create-tags \
--resources i-0123456789abcdef0 \
--tags Key=Name,Value=web-01 \
Key=Environment,Value=production \
Key=Project,Value=soundscode \
Key=Owner,Value=platform-team
# Find every instance in the dev environment
aws ec2 describe-instances \
--filters "Name=tag:Environment,Values=dev" \
--query "Reservations[].Instances[].InstanceId"When to use it
- A finance team uses Environment and CostCenter tags on every resource to generate per-team cost reports in AWS Cost Explorer each month.
- An operations team tags all production resources with Environment=prod and uses tag-based IAM conditions to prevent developers from modifying them.
- A company enforces tagging via AWS Config rules that mark non-compliant resources so untagged resources are identified and remediated automatically.
More examples
Tag Multiple Resources at Once
Applies three tags to three different resource types simultaneously, enforcing consistent tagging across an environment.
aws ec2 create-tags \
--resources i-0abc123 vol-0def456 sg-0ghi789 \
--tags \
Key=Environment,Value=production \
Key=CostCenter,Value=platform \
Key=Owner,Value=backend-teamFind All Untagged EC2 Instances
Queries for EC2 instances that are missing the mandatory Environment tag, helping audit tagging compliance.
aws ec2 describe-instances \
--query 'Reservations[].Instances[?!not_null(Tags[?Key==`Environment`].Value | [0])].{ID:InstanceId,State:State.Name}' \
--output tableFilter Cost Report by Tag
Groups monthly AWS spending by the CostCenter tag value, enabling per-team or per-project cost attribution.
aws ce get-cost-and-usage \
--time-period Start=2024-01-01,End=2024-02-01 \
--granularity MONTHLY \
--metrics BlendedCost \
--group-by Type=TAG,Key=CostCenter \
--query 'ResultsByTime[].Groups[].{Team:Keys[0],Cost:Metrics.BlendedCost.Amount}' \
--output table
Discussion