Sub topic 6
Finding and removing idle resources
This chapter assumes you can run AWS CLI commands, read JSON, and know the basics of EC2, EBS and Elastic IP addresses. It also builds on the previous chapters on cost visibility and tagging.
What counts as idle
An idle resource is something you pay for that does no useful work. Compute is billed while an instance runs. Storage is billed while it exists. So a forgotten resource keeps charging until someone deletes it.
Common idle resources on AWS:
- EBS volumes in the
availablestate, which means they are not attached to any instance. - Old EBS snapshots whose source volume or image no longer exists.
- Elastic IP addresses that are not associated with a running instance.
- Load balancers with no registered targets or no traffic.
- Stopped or low-use EC2 instances. A stopped instance does not bill for compute, but its attached volumes still bill for storage.
- Test environments left running after a project ends.
Idle is different from oversized. An idle resource should usually be deleted or scheduled. An oversized one is still useful and should be resized, which the next chapter covers.
A detection workflow
Follow the same steps each time:
- Find candidates with a query.
- Identify the owner from tags or CloudTrail.
- Confirm the resource is unused, using metrics where possible.
- Back up if the data might matter.
- Delete or schedule.
Example: unattached EBS volumes
This command lists volumes that are not attached to any instance:
aws ec2 describe-volumes \
--filters Name=status,Values=available \
--query 'Volumes[].{Id:VolumeId,SizeGiB:Size,Created:CreateTime}' \
--output tableThe table shows the volume ID, size in GiB, and creation time. Large, old volumes are the best candidates, because they cost the most and are least likely to be in use. Check each volume's tags with aws ec2 describe-tags to find an owner.
Before deleting a volume, take a snapshot. A snapshot costs less than a volume of the same size because it stores only the used blocks.
aws ec2 create-snapshot \
--volume-id vol-0123456789abcdef0 \
--description "Backup before deleting idle volume"When the snapshot is complete, delete the volume:
aws ec2 delete-volume --volume-id vol-0123456789abcdef0Using metrics to confirm low use
For running instances, look at CloudWatch metrics before you decide. An instance with CPU under about 5 percent and almost no network traffic for two weeks is a strong candidate. Check CPUUtilization, NetworkIn and NetworkOut together, because CPU alone can mislead. A memory-bound or network-bound workload may show low CPU while still doing real work. AWS Compute Optimizer and Trusted Advisor also flag idle resources.
Common errors
- Deleting without an owner check. A volume that looks idle may hold a monthly backup target or a disaster recovery copy. Tag first, wait, then delete.
- Judging by a short window. A batch job that runs once a quarter looks idle most of the time. Check a period that covers the full cycle.
- Forgetting dependents. Deleting an instance does not always delete its volumes. This depends on the
DeleteOnTerminationsetting, so check for leftovers after terminating. - One-time cleanup. Without a recurring check, idle resources return. Run the queries on a schedule and report the results to owners.
Exercise
An EBS volume has been in the available state for 90 days, has no tags, and is 500 GiB. What steps should you take before it stops costing you money, and why not delete it immediately?
Show answer
Find the owner, for example through CloudTrail events for the volume's creation, and ask whether it is needed. If there is no owner, tag it for review and wait a grace period. Then create a snapshot, since the data may matter and a snapshot costs less than the volume, and delete the volume only after that. Deleting immediately risks permanent data loss because deletion cannot be undone.