AWS Builder Center

How to find unused AWS resources (and who left them there)

Find unattached volumes, idle load balancers, old snapshots and other unused AWS resources with the CLI, check they're safe to delete, and see who made them.

Every AWS account that has been running for a few years contains things nobody can explain. A volume called  test-2 . A load balancer with no targets. A snapshot from a backup job that was replaced in 2022. Each costs a few pounds a month, so nobody chases it, but they add up, and the harder question is not "is this unused?" but "who made it, and is it safe to delete?"
This article covers both: the CLI commands to find the common types, the checks to run before you delete anything, and how to trace a resource to a person or team.

Why unused resources pile up

Three patterns account for most of it.
  • Tests and experiments. Someone follows a tutorial or tries a proof of concept, and cleaning up is the step that gets skipped. Often it happens in a region the team never looks at.
  • Leavers. When someone leaves, their IAM user is disabled but the things they created carry on. Nobody knows whether the 200 GiB volume is theirs or the finance team's archive.
  • "Temporary" things. A NAT gateway for a migration, a snapshot "just in case" before an upgrade. Without an expiry date, temporary becomes permanent.
Some real numbers, using on-demand list prices (they vary by region, so treat these as "about"):
  • A 500 GiB gp3 volume in eu-west-2 is about $46 a month.
  • An Application Load Balancer costs about $16 to $19 a month before any traffic, depending on region.
  • A public IPv4 address costs $0.005 an hour, about $3.65 a month. Since February 2024 that applies to every public IPv4 address, attached or not.
  • A NAT gateway is about $33 a month in us-east-1 before any data charges.
None of these is dramatic alone. Twenty of them are a real line on the bill.

Look in every region

The console shows one region at a time, and the expensive strays are often in the one you forgot. Wrap any of the commands below in a loop:
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,VolumeType,CreateTime]' --output text
done
Run these in a read-only session. Everything in the "find" steps below is a  Describe* ,  List*  or  Get*  call and changes nothing.

Unattached EBS volumes

When an instance is terminated, volumes that were not set to delete on termination stay behind, billed per GB-month.
aws ec2 describe-volumes \
--filters Name=status,Values=available \
--query 'Volumes[].[VolumeId,Size,VolumeType,CreateTime,Tags[?Key==`Name`]|[0].Value]' \
--output table
Before deleting: check the volume's tags and  CreateTime , look up who created it (see below), then take a snapshot so you can undo the decision:
aws ec2 create-snapshot --volume-id vol-0123456789abcdef0 \
--description "Final snapshot before deleting unattached volume"
aws ec2 delete-volume --volume-id vol-0123456789abcdef0
A snapshot of an unused volume costs less than the volume, and you can keep it for a month as a safety net.

gp2 volumes that should be gp3

This one is not unused, just overpriced. In us-east-1 gp3 is about $0.08 per GB-month against $0.10 for gp2, and gp3 includes 3,000 IOPS and 125 MB/s regardless of size.
aws ec2 describe-volumes --filters Name=volume-type,Values=gp2 \
--query 'Volumes[].[VolumeId,Size,Iops,Attachments[0].InstanceId]' --output table
Migration is online:
aws ec2 modify-volume --volume-id vol-0123456789abcdef0 --volume-type gp3
Check first: gp2 volumes over 1,000 GiB get a baseline above 3,000 IOPS (3 IOPS per GiB), so a large, busy gp2 volume needs IOPS or throughput provisioned on gp3 to match. A volume can only be modified once every six hours.

Old snapshots and orphaned RDS snapshots

Snapshots are kept until something deletes them. List the oldest first:
aws ec2 describe-snapshots --owner-ids self \
--query 'sort_by(Snapshots,&StartTime)[:25].[SnapshotId,StartTime,VolumeSize,Description]' \
--output table
(JMESPath cannot compare date strings with  < , which is why this sorts instead of filtering.)
Before deleting:
  • A snapshot used by an AMI cannot be deleted until the AMI is deregistered. Descriptions beginning "Created by CreateImage" are the usual sign.
  • Snapshots from AWS Backup or Data Lifecycle Manager are managed for you. Delete the policy or recovery point, not the snapshot.
  • Snapshots are incremental, so deleting one frees only the blocks no other snapshot needs. The per-snapshot size is an upper bound on what you save.
For RDS, manual snapshots outlive the database they came from. Compare snapshots with the databases that still exist:
aws rds describe-db-snapshots --snapshot-type manual \
--query 'DBSnapshots[].[DBSnapshotIdentifier,DBInstanceIdentifier,SnapshotCreateTime,AllocatedStorage]' \
--output table
aws rds describe-db-instances --query 'DBInstances[].DBInstanceIdentifier' --output text
Any snapshot whose  DBInstanceIdentifier  is missing from the second list is orphaned. That may be intentional (a final snapshot kept for compliance), so confirm with an owner. For Aurora use  describe-db-cluster-snapshots .

Old AMIs

aws ec2 describe-images --owners self \
--query 'sort_by(Images,&CreationDate)[:25].[ImageId,Name,CreationDate]' --output table
Check whether anything still uses the image:
aws ec2 describe-instances --filters Name=image-id,Values=ami-0123456789abcdef0 \
--query 'Reservations[].Instances[].InstanceId'
Also search your launch templates and Auto Scaling groups, since they may reference the AMI without a running instance. Deregistering an AMI does not delete its snapshots; remove those separately.

Elastic IPs and public IPv4 addresses

Unassociated Elastic IPs:
aws ec2 describe-addresses \
--query 'Addresses[?AssociationId==null].[PublicIp,AllocationId]' --output table
Because in-use public IPv4 addresses are charged too, it is also worth seeing where they all are:
aws ec2 describe-network-interfaces \
--query 'NetworkInterfaces[?Association.PublicIp].[NetworkInterfaceId,Association.PublicIp,Description]' \
--output table
Before releasing: an Elastic IP may be on the allow list of a customer or a partner's firewall. Once released you cannot be sure of getting the same address back. Search your DNS records for the address first.

Idle load balancers

Load balancers cost by the hour whether or not traffic flows. Start with a list, then check for targets and traffic:
aws elbv2 describe-load-balancers \
--query 'LoadBalancers[].[LoadBalancerName,Type,CreatedTime,LoadBalancerArn]' --output table

aws elbv2 describe-target-groups --load-balancer-arn <lb-arn> \
--query 'TargetGroups[].TargetGroupArn' --output text

aws elbv2 describe-target-health --target-group-arn <tg-arn> \
--query 'TargetHealthDescriptions[].[Target.Id,TargetHealth.State]'
No registered targets is a strong sign. For traffic, check request count over two weeks (GNU  date  shown; on macOS use  date -u -v-14d +%FT%TZ ):
aws cloudwatch get-metric-statistics --namespace AWS/ApplicationELB \
--metric-name RequestCount \
--dimensions Name=LoadBalancer,Value=app/my-alb/0123456789abcdef \
--start-time "$(date -u -d '14 days ago' +%FT%TZ)" --end-time "$(date -u +%FT%TZ)" \
--period 86400 --statistics Sum --query 'Datapoints[].Sum'
The  LoadBalancer  value is the end of the ARN, from  app/  onwards. No datapoints at all means no requests. Classic load balancers use the  AWS/ELB  namespace and Network Load Balancers  AWS/NetworkELB .

Stopped instances and their volumes

A stopped instance costs nothing for compute, but its volumes are still billed.
aws ec2 describe-instances --filters Name=instance-state-name,Values=stopped \
--query 'Reservations[].Instances[].[InstanceId,StateTransitionReason,BlockDeviceMappings[].Ebs.VolumeId|join(`,`,@)]' \
--output table
 StateTransitionReason  includes the stop date, for example "User initiated (2026-08-01 10:12:03 GMT)". An instance stopped for months is rarely coming back. Snapshot or create an AMI first if you are unsure.

NAT gateways with no traffic

aws ec2 describe-nat-gateways --filter Name=state,Values=available \
--query 'NatGateways[].[NatGatewayId,VpcId,CreateTime]' --output table

aws cloudwatch get-metric-statistics --namespace AWS/NATGateway \
--metric-name BytesOutToDestination \
--dimensions Name=NatGatewayId,Value=nat-0123456789abcdef0 \
--start-time "$(date -u -d '14 days ago' +%FT%TZ)" --end-time "$(date -u +%FT%TZ)" \
--period 86400 --statistics Sum --query 'Datapoints[].Sum'
Near-zero bytes over two weeks means nothing in the private subnets is reaching the internet. Before deleting, check the route tables that point at it:  aws ec2 describe-route-tables --filters Name=route.nat-gateway-id,Values=nat-0123456789abcdef0 . A job that runs quarterly would look idle for a fortnight.

Log groups with no retention

CloudWatch log groups default to "never expire", and storage is about $0.03 per GB-month, forever.
aws logs describe-log-groups \
--query 'sort_by(logGroups[?!retentionInDays],&storedBytes)[-20:].[logGroupName,storedBytes]' \
--output table
Setting retention is reversible in the sense that matters (you only lose logs older than the period):
aws logs put-retention-policy --log-group-name /aws/lambda/my-function --retention-in-days 30
If you need the old logs for audit, export them to S3 first. Check any compliance requirement before choosing the period.

Who created it?

Deleting something because it looks unused is how outages happen. Find the owner first.
Tags are the best long-term answer. Look for  Owner ,  CreatedBy  or  Team . Note that volumes created at instance launch do not inherit the instance's tags unless you add  TagSpecifications  for  ResourceType=volume .
CloudTrail event history answers it for recent resources. It keeps 90 days of management events per region, and you query it in the region where the resource lives:
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=ResourceName,AttributeValue=vol-0123456789abcdef0 \
--query 'Events[].[EventTime,EventName,Username]' --output table
You can also search by event name, such as  AttributeKey=EventName,AttributeValue=CreateLoadBalancer .
Some things to know:
  • Volumes created with an instance appear under  RunInstances , not  CreateVolume .
  • For assumed roles,  Username  is the role session name, which with SSO is usually the person's identity, but with a CI role is just the pipeline.
  • Only one attribute can be used per lookup, and the API is rate limited to a couple of requests a second.
  • Older than 90 days returns nothing. Create a trail that writes to S3 now, so that the answer exists next year (query it with Athena).
  • If the resource sits in Terraform state or a CloudFormation stack, delete it there. A manual delete comes back on the next apply.
Then, going forward, enforce an  Owner  tag at creation with a tag policy or an IAM condition, so you never need to do this detective work again.

A safe deletion routine

  1. Find it, and record what it costs per month.
  1. Identify the owner from tags, then CloudTrail, then asking.
  1. Ask: delete, keep (with a reason), or snooze.
  1. Take a snapshot or backup where the resource holds data.
  1. Tag it  delete-after=<date>  and, where you can, stop or detach it first. If nobody shouts, delete.
  1. Write down the decision.

Automate it

If you would rather not paste these commands every month,  costwatch  is a free, open-source (Apache 2.0) CLI that runs these checks across every enabled region, prices each finding with that region's list prices, and can look up owners from tags or CloudTrail. It uses read-only API calls and runs locally with your own credentials.
pipx install costwatch # or: uv tool install costwatch
costwatch scan --owners
Here it is running on a demo account:


And the same job by hand with the AWS CLI, then with costwatch:


Strays (getstrays.com) is the hosted version, which also asks the owner in Slack or Teams.
Whichever route you take, make it recurring. One clean-up helps; a weekly look keeps the account clean.


Jon Melia is the founder of Cloud Adept, a UK AWS consultancy, which makes Strays and costwatch.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article