Sub topic 6
Finding and Removing Idle Resources
This chapter assumes you can run AWS CLI commands, read JSON, and know what EC2 instances, EBS volumes, and Elastic IP addresses are. It also assumes you have already seen how to group spend by service, as covered in the cost visibility chapter.
What "idle" means
An idle resource is one that you pay for and that does no useful work. Idle resources usually come from forgotten experiments, finished projects, and automation that creates things but never cleans them up.
Idle is different from oversized. An oversized resource does real work but has more capacity than it needs. Rightsizing, covered in the next chapter, handles that case. Here the question is simpler: should this resource exist at all?
Common idle resources on AWS:
| Resource | Why it keeps costing money | Typical signal |
|---|---|---|
| Unattached EBS volume | Storage is billed per GiB-month whether or not an instance uses it | Status is `available` |
| Old EBS snapshot | Snapshots are billed for stored data | Source volume or AMI no longer exists |
| Unassociated Elastic IP | Public IPv4 addresses are billed, including unused ones | No association ID |
| Stopped EC2 instance | Compute charges stop, but attached volumes still bill | State is `stopped` for weeks |
| Idle load balancer | Billed per hour regardless of traffic | No healthy targets or near-zero requests |
| Idle NAT gateway | Billed per hour plus per GB processed | Almost no bytes through the gateway |
| Unused RDS instance | Billed per hour whether or not anyone connects | Zero database connections |
| Orphaned test environment | Combines several of the above | Owner tag points to a person who left |
The detection workflow
Finding idle resources is a loop. You start from spend, narrow to candidates, check usage evidence, confirm ownership, and only then act.
Start with the money. The Cost Explorer call below returns October 2026 spend grouped by service. Services with a high bill and low business value are the first places to look.
aws ce get-cost-and-usage \
--time-period Start=2026-10-01,End=2026-11-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=DIMENSION,Key=SERVICEFinding unattached EBS volumes
An EBS volume in the available state is not attached to any instance. This is one of the most common sources of waste, because terminating an instance does not always delete its volumes.
aws ec2 describe-volumes \
--filters Name=status,Values=available \
--query 'Volumes[].{Id:VolumeId,SizeGiB:Size,Created:CreateTime}' \
--output tableThe command only covers the Region set in your CLI configuration. Run it once per Region, or loop over Regions as shown later in this chapter.
A volume that appears here is a candidate, not a verdict. Some volumes are detached on purpose. For example, a team may keep a volume as a warm copy for disaster recovery, or detach it during a maintenance window.
Finding other candidates
Unassociated Elastic IP addresses have no AssociationId field:
aws ec2 describe-addresses \
--query 'Addresses[?AssociationId==null].{Ip:PublicIp,Allocation:AllocationId}' \
--output tableStopped instances show up with a state filter. The StateTransitionReason field often includes a timestamp, which tells you how long the instance has been stopped.
aws ec2 describe-instances \
--filters Name=instance-state-name,Values=stopped \
--query 'Reservations[].Instances[].{Id:InstanceId,Type:InstanceType,Reason:StateTransitionReason}' \
--output tableLoad balancers need a usage check. A load balancer with no registered targets or no requests is a strong candidate. You can read request counts from CloudWatch, which the next section covers.
Confirming with usage metrics
A resource's state tells you little about whether anyone uses it. A running instance can sit at 1 percent CPU for months. Metrics give you evidence.
Amazon CloudWatch stores metrics for most AWS services. For a compute instance, check CPU and network traffic over a window long enough to include monthly jobs. Fourteen days is a common minimum, and thirty days is safer.
The following command returns the daily maximum CPU for one instance. Replace the instance ID with your own. The date arithmetic assumes GNU date, which is standard on Linux. On macOS, use date -u -v-30d instead.
aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name CPUUtilization \
--dimensions Name=InstanceId,Value=i-0123456789abcdef0 \
--start-time "$(date -u -d '30 days ago' +%Y-%m-%dT%H:%M:%SZ)" \
--end-time "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--period 86400 \
--statistics Maximum \
--query 'sort_by(Datapoints,&Timestamp)[].{Day:Timestamp,MaxCPU:Maximum}' \
--output tableUse the maximum, not the average. An average hides short, important bursts. If the daily maximum stays under a few percent for the whole window, the instance is probably idle.
Pick the metric that matches the service:
| Resource | Metric to check | Idle looks like |
|---|---|---|
| EC2 instance | `CPUUtilization`, `NetworkIn`, `NetworkOut` | Low CPU and near-zero network |
| RDS database | `DatabaseConnections` | Zero connections |
| Application Load Balancer | `RequestCount` | Zero or near-zero requests |
| NAT gateway | `BytesOutToDestination` | Near-zero bytes |
| EBS volume | `VolumeReadOps`, `VolumeWriteOps` | No reads or writes (attached but unused) |
CPU alone can mislead. A cache server or a message consumer may use little CPU and still be essential. Always pair CPU with network or application-level metrics.
Checking across Regions
Idle resources often hide in Regions nobody uses regularly. The loop below lists unattached volumes in every enabled Region.
for region in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do
echo "== $region =="
aws ec2 describe-volumes \
--region "$region" \
--filters Name=status,Values=available \
--query 'Volumes[].[VolumeId,Size,CreateTime]' \
--output text
doneFor a managed view, AWS also offers Trusted Advisor and Compute Optimizer. Both flag low-utilization resources. Which checks you see depends on your support plan, so verify what is available in your account before relying on them.
Deciding: delete, stop, or keep
Deleting is not always right. Choose the least risky action that stops the charge.
- Delete when the resource is clearly abandoned and holds no data you need. Examples are an unassociated Elastic IP or an empty load balancer.
- Snapshot, then delete when the resource holds data that might matter. For an EBS volume, a snapshot costs less than the volume because it stores only used blocks, and you can restore from it.
- Stop when you may need the resource again soon. A stopped instance stops compute billing, but its EBS volumes and Elastic IPs keep billing.
- Keep and tag when the resource is intentionally idle, such as a disaster recovery standby. Add a tag that records the reason, so the next reviewer does not repeat the investigation.
Here is the snapshot-then-delete sequence for one volume. The volume ID is a placeholder.
VOLUME_ID=vol-0123456789abcdef0
SNAPSHOT_ID=$(aws ec2 create-snapshot \
--volume-id "$VOLUME_ID" \
--description "Backup before idle cleanup" \
--tag-specifications 'ResourceType=snapshot,Tags=[{Key=cleanup,Value=pre-delete-backup}]' \
--query SnapshotId --output text)
aws ec2 wait snapshot-completed --snapshot-ids "$SNAPSHOT_ID"
aws ec2 delete-volume --volume-id "$VOLUME_ID"The wait step matters. Deleting the volume before the snapshot completes can leave you with an incomplete backup. Remember that the snapshot is now a resource you pay for, so give it an expiry plan or you will find it in the next cleanup.
Common errors and edge cases
- Judging by state alone. An
availablevolume may be a deliberate standby. Check tags and ask the owner. - Too short a window. A quarterly reporting server looks idle for most of the quarter. Use a window that covers the longest job cycle you know of.
- Forgetting dependencies. Deleting a volume used by an Auto Scaling launch template or a snapshot-based AMI can break future launches. Check what references the resource first.
- Leaving orphaned snapshots. Deleting an AMI does not delete the snapshots behind it. Deregister the AMI, then delete its snapshots.
- Deleting without ownership. Resources with no owner tag are the hardest to judge. This is why the tagging chapter comes first. A required
ownertag turns "who owns this?" into a lookup. - One-time cleanup. Idle resources come back. Without a recurring review or automation, the same waste returns within months.
Making cleanup repeatable
Manual sweeps find waste once. To keep it from returning:
- Run the detection commands on a schedule and send the output to the resource owners or a shared channel.
- Require
ownerandexpirytags on non-production resources, and flag anything past its expiry date. - Create temporary environments through infrastructure as code, so that destroying the stack removes everything it created.
- Use a grace period. Notify the owner, wait a fixed number of days, then act.
Summary
Finding idle resources works in four steps: start from spend, build a candidate list from resource state, confirm with usage metrics over a long enough window, and confirm ownership before you act. Choose delete, snapshot-then-delete, stop, or keep based on how reversible the action is and how sure you are.
Exercise
The command aws ec2 describe-volumes --filters Name=status,Values=available returns a 500 GiB volume created eight months ago with no owner tag. Describe the steps you would take before removing it, and name the safest way to remove it.
Show answer
First, check whether anything references the volume, such as a launch template or a recovery runbook, and try to find an owner through CloudTrail history or team channels. Second, check whether it is a deliberate standby by looking at its other tags. If no owner or reason turns up, create a snapshot, wait for it to complete with aws ec2 wait snapshot-completed, tag the snapshot with its origin and an expiry date, and then delete the volume. This keeps the data recoverable at a lower storage cost, and a later review can delete the snapshot once the grace period passes without complaints.
Exercise
An EC2 instance shows an average CPU of 2 percent over 30 days. Why is that not enough to call it idle, and which additional evidence would you collect?
Show answer
An average hides short bursts, so the instance may handle periodic spikes. Check the daily maximum CPU instead, and add network in and out to catch workloads that are light on CPU, such as caches or queue consumers. Also look at application-level signals, such as request counts or connections, and confirm that the window covers any monthly or quarterly job cycle.