What counts as an unused AWS resource, and why do they pile up?

An unused resource is one that keeps billing while nothing depends on it. Each resource type has its own measurable sign of disuse, so check for that sign directly instead of guessing from names or tags. Elastic IPs matter most here: AWS bills public IPv4 addresses, and an unassociated Elastic IP is pure cost.

Resource Disuse signal Detection command
Elastic IP No AssociationId aws ec2 describe-addresses
EBS volume State is available (not attached) aws ec2 describe-volumes --filters Name=status,Values=available
ALB / NLB No target groups, no registered targets, or no healthy targets aws elbv2 describe-target-groups, aws elbv2 describe-target-health
Any load balancer Zero traffic over a lookback window aws cloudwatch get-metric-statistics (RequestCount for ALB, NewFlowCount for NLB)

These resources pile up because creation and deletion follow different paths:

  • Partial IaC destroys. A destroy can fail midway or lose track of its state, which leaves orphans that no tool knows about.
  • Console experiments. Resources created by hand never enter state files.
  • Missing delete-on-termination. If this flag is not set on a volume, terminating the instance leaves the volume behind.
  • Abandoned Kubernetes Services. Deleting a cluster before its LoadBalancer Services can leave the provisioned load balancers running.

This checklist is for backend and platform engineers who own AWS accounts. Run it on a regular schedule. Also run it after migrations, environment teardowns and unexplained cost spikes, because those are the events most likely to leave orphans behind.

Who should use this checklist?

Use it if you are responsible for an AWS bill or for the accounts that generate it, and nobody else is already doing this job systematically. In practice that covers:

  • Platform and infrastructure engineers who run shared accounts, VPCs and clusters, and who end up owning resources that other teams created and forgot.
  • Backend engineers on small teams who manage their own AWS accounts without a dedicated cost or FinOps function.
  • Teams that run many accounts or regions, where waste in an account or region nobody looks at goes unnoticed the longest.
  • Teams that use Terraform, CloudFormation or Kubernetes heavily, because failed destroys and deleted clusters are the most common sources of orphans.
  • Whoever is asked to explain a cost spike, since unattached volumes and idle load balancers are quick to rule in or out.

You need permission to call the read-only describe APIs, CloudWatch and CloudTrail in each account, and, for the cross-account scan, a read-only role you can assume in every member account. If your organization already has a central team or tool that tags, reports and removes idle resources, use this checklist to verify its coverage, not to run a second deletion process alongside it.

How does the detection work?

Every check in this article follows the same three steps, and none of them modify anything:

  1. Read resource state from the AWS API. The describe calls return each resource's current configuration. An unused resource shows a specific field value: an Elastic IP with no AssociationId, a volume with status available, a load balancer with no target groups or no healthy targets. Filtering on those fields gives you a candidate list without logging into the console.
  2. Confirm with usage data where configuration isn't enough. A load balancer can be fully configured and still receive no requests. CloudWatch metrics such as RequestCount or ProcessedBytes, summed over a long lookback window, tell you whether anything actually used it.
  3. Attach context. Region, account ID, tags, CloudTrail creation events and IaC state turn a bare resource ID into a finding someone can act on: who created it, what it belonged to, and where it should be deleted from.

The same calls run in a loop over every enabled region and, through sts assume-role, over every account in the organization. The output is a report, not a deletion. That report feeds the staged cleanup workflow described later, which tags candidates, notifies owners, waits out a grace period and only then deletes.

How do you find unattached Elastic IPs, EBS volumes and old snapshots?

Elastic IPs are the cheapest resource to find. AWS bills for public IPv4 addresses, and an allocated Elastic IP that isn't associated with a running resource costs money and serves no traffic. Rates and billing rules change, so check the current AWS VPC pricing page for the actual figure. To list unassociated addresses, run aws ec2 describe-addresses --query 'Addresses[?AssociationId==null]'. Also check addresses attached to stopped instances. They pass that filter but are just as idle.

Unattached EBS volumes

Run aws ec2 describe-volumes --filters Name=status,Values=available to return volumes that exist but are not attached to any instance. These volumes keep incurring storage charges, plus provisioned IOPS or throughput on volume types that bill for them. CreateTime tells you how old a volume is. It does not tell you when the volume was detached, and the volume record doesn't store a detach timestamp. To estimate how long a volume has been orphaned, compare CreateTime with its tags (Name, environment, or a ticket reference often points to a deleted stack). If CloudTrail retention covers the period, look for DetachVolume events.

Old snapshots

Run aws ec2 describe-snapshots --owner-ids self to list only your own snapshots. Without that flag you also get public ones. Look for snapshots whose VolumeId no longer resolves to an existing volume and that no registered AMI references. To check the AMIs, list them with aws ec2 describe-images --owners self and compare the snapshot IDs in their block device mappings. Snapshots that serve neither purpose usually survive because nobody remembers why they were taken, so check StartTime and the description before you flag them.

#!/usr/bin/env bash
set -euo pipefail

echo "== Elastic IPs with no association (billed, serving no traffic) =="
aws ec2 describe-addresses \
  --query 'Addresses[?AssociationId==null].[PublicIp,AllocationId]' \
  --output text

echo "== EBS volumes not attached to any instance =="
aws ec2 describe-volumes --filters Name=status,Values=available \
  --query 'Volumes[].[VolumeId,Size,VolumeType,CreateTime,Tags[?Key==`Name`]|[0].Value]' \
  --output text

echo "== Own snapshots whose source volume is gone and no own AMI uses =="
existing_vols=$(aws ec2 describe-volumes --query 'Volumes[].VolumeId' --output text)
ami_snaps=$(aws ec2 describe-images --owners self \
  --query 'Images[].BlockDeviceMappings[].Ebs.SnapshotId' --output text)

aws ec2 describe-snapshots --owner-ids self \
  --query 'Snapshots[].[SnapshotId,VolumeId,StartTime]' --output text |
while read -r snap vol start; do
  # Skip if the source volume still exists.
  grep -qw -- "$vol" <<<"$existing_vols" && continue
  # Skip if a registered AMI references this snapshot.
  grep -qw -- "$snap" <<<"$ami_snaps" && continue
  # Candidate for review: check StartTime and the description before deleting.
  echo "$snap $vol $start"
done

A read-only AWS CLI script that lists unassociated Elastic IPs, unattached EBS volumes with their age and Name tag, and your own snapshots whose source volume no longer exists and that no AMI you own references.

How do you identify idle load balancers?

Load balancers bill per hour whether or not they carry traffic, so they are worth checking on their own. Start with aws elbv2 describe-load-balancers, which returns both Application and Network Load Balancers along with their ARNs and Type. For each ARN, call aws elbv2 describe-target-groups --load-balancer-arn. An empty result is the strongest signal. One exception: an ALB whose listeners only return fixed responses or redirects can be doing real work with no target groups at all. For each target group, run aws elbv2 describe-target-health --target-group-arn. A group with no registered targets, or with every target unhealthy, usually means the backend was torn down and the load balancer was left behind.

Classic Load Balancers use a separate API. Run aws elb describe-load-balancers; an empty Instances list means nothing is registered. aws elb describe-instance-health shows the health of any instances that are registered.

Configuration checks only tell you that a load balancer could serve traffic. A load balancer with healthy targets can still receive no requests if its DNS record was repointed or its clients were retired. To confirm it is idle, use CloudWatch:

  • ALBs: RequestCount in AWS/ApplicationELB.
  • NLBs: ProcessedBytes or ActiveFlowCount in AWS/NetworkELB.
  • Classic Load Balancers: RequestCount in AWS/ELB.

Look back at least 90 days, longer if you know of annual jobs, so monthly and quarterly batch traffic shows up. CloudWatch keeps fine-grained data for only a few weeks, so use an hourly or daily period for long windows. Sum the metric over the window. A total of zero is what justifies a load balancer as a cleanup candidate.

#!/usr/bin/env bash
set -euo pipefail
DAYS=90   # long enough to catch monthly and quarterly jobs
START=$(date -u -d "${DAYS} days ago" +%Y-%m-%dT%H:%M:%SZ)   # GNU date
END=$(date -u +%Y-%m-%dT%H:%M:%SZ)

while read -r arn type <&3; do
  # Count target groups and healthy targets attached to this load balancer
  tgs=$(aws elbv2 describe-target-groups --load-balancer-arn "$arn" \
    --query 'TargetGroups[].TargetGroupArn' --output text)
  tg_count=0; healthy=0
  for tg in $tgs; do
    tg_count=$((tg_count + 1))
    n=$(aws elbv2 describe-target-health --target-group-arn "$tg" \
      --query "length(TargetHealthDescriptions[?TargetHealth.State=='healthy'])" --output text)
    healthy=$((healthy + n))
  done

  # Healthy targets do not prove traffic, so check the metric that matches the type
  case "$type" in
    application) ns=AWS/ApplicationELB; metric=RequestCount ;;
    network)     ns=AWS/NetworkELB;     metric=ProcessedBytes ;;
    *) continue ;;   # skip gateway load balancers
  esac
  dim=${arn#*:loadbalancer/}   # dimension value is app/<name>/<id> or net/<name>/<id>

  # Daily period keeps a 90-day window within CloudWatch's coarser retention tiers
  total=$(aws cloudwatch get-metric-statistics --namespace "$ns" --metric-name "$metric" \
    --dimensions Name=LoadBalancer,Value="$dim" --start-time "$START" --end-time "$END" \
    --period 86400 --statistics Sum --query 'sum(Datapoints[].Sum)' --output text)

  echo -e "${dim}\ttarget_groups=${tg_count}\thealthy=${healthy}\t${metric}_${DAYS}d=${total}"
done 3< <(aws elbv2 describe-load-balancers \
  --query 'LoadBalancers[].[LoadBalancerArn,Type]' --output text)

aws elb describe-load-balancers \
  --query 'LoadBalancerDescriptions[].[LoadBalancerName,length(Instances)]' --output text

A bash loop that lists each ALB and NLB with its target-group count, healthy target count and 90-day CloudWatch traffic total, then lists Classic Load Balancers with their registered instance counts.

How do you scan every region and account and find each resource's owner?

Running these checks only in your default region misses most of the waste. Resources left over from a migration, a one-off load test, or a demo built in a region closer to a customer tend to stay where nobody's console is pointed. Get the list of regions enabled for the account with aws ec2 describe-regions --query "Regions[].RegionName" --output text. Loop over that list, pass --region to each detection command, and write every finding with its region and account ID attached.

Run the same loop across the whole organization. From the management account or a delegated admin account, aws organizations list-accounts gives you every member account. For each one, assume a read-only audit role with aws sts assume-role and run the region loop using those credentials. Deploy the role to all accounts the same way, for example through StackSets, so the scan doesn't fail on accounts that lack it.

Assign an owner before acting

Check three things for each finding:

  • Tags. owner, service and environment tags usually answer the question. The aws:cloudformation:stack-name tag shows the resource belongs to a stack, and deleting it outside that stack causes drift.
  • CloudTrail. Look for the creation event, such as CreateVolume, AllocateAddress or CreateLoadBalancer. Its userIdentity field shows who created the resource. Event history covers only the last 90 days, so for older resources you need to query a trail stored in S3.
  • IaC state. Search your Terraform state or CloudFormation stacks for the resource ID. If code still manages the resource, delete it there. Otherwise the next apply recreates it.
#!/usr/bin/env bash
set -euo pipefail
ROLE_NAME="OrgAuditReadOnly"   # placeholder: read-only role deployed to all accounts
OUT="findings.tsv"
printf 'account\tregion\ttype\tid\towner_tag\n' > "$OUT"

for ACCOUNT in $(aws organizations list-accounts \
    --query "Accounts[?Status=='ACTIVE'].Id" --output text); do
  (  # subshell keeps assumed-role credentials scoped to this account
    read -r AK SK ST < <(aws sts assume-role \
      --role-arn "arn:aws:iam::${ACCOUNT}:role/${ROLE_NAME}" \
      --role-session-name idle-resource-scan \
      --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" --output text)
    export AWS_ACCESS_KEY_ID="$AK" AWS_SECRET_ACCESS_KEY="$SK" AWS_SESSION_TOKEN="$ST"

    # describe-regions returns only regions enabled for this account by default
    for REGION in $(aws ec2 describe-regions --region us-east-1 \
        --query "Regions[].RegionName" --output text); do
      # EBS volumes not attached to any instance, with the owner tag if one exists
      aws ec2 describe-volumes --region "$REGION" --filters Name=status,Values=available \
        --query "Volumes[].[VolumeId, Tags[?Key=='owner'].Value | [0]]" --output text |
        awk -v a="$ACCOUNT" -v r="$REGION" 'NF {print a"\t"r"\tvolume\t"$1"\t"$2}' >> "$OUT"

      # Elastic IPs with no association
      aws ec2 describe-addresses --region "$REGION" \
        --query "Addresses[?AssociationId==null].[AllocationId, Tags[?Key=='owner'].Value | [0]]" \
        --output text |
        awk -v a="$ACCOUNT" -v r="$REGION" 'NF {print a"\t"r"\teip\t"$1"\t"$2}' >> "$OUT"
    done
  )
done

A bash loop that assumes a read-only role in each organization account, scans every enabled region for unattached EBS volumes and unassociated Elastic IPs, records the owner tag, and shows a CloudTrail lookup for untagged findings.

How does a staged, reversible cleanup workflow work?

detect -> tag (delete-after date) -> notify owner -> grace period
                                                        |
           record <- delete <- final snapshot (volumes) <+
                                                        |
                    owner objects? --> remove tag, exempt

Once you know who owns a resource, the cleanup itself should run as a pipeline, not a single destructive pass. Detection only produces candidates. The pipeline tags each candidate with a deletion date, for example cleanup:delete-after=2026-12-01, and sends that list to the owner. The owner can cancel the deletion by removing the tag. Detection rules miss context such as a DR volume or a load balancer reserved for a launch, and a grace period gives the owner time to supply it. A one-off deletion script has no step where that can happen.

When the date passes, the pipeline takes a final snapshot of each EBS volume, then deletes the resource. It writes a record of every deletion: resource ID, region, account, tags, owner and snapshot ID. That record is what you use to trace or restore a resource when someone asks about it later. Give each final snapshot its own expiry tag, such as 30 or 90 days, and have the same pipeline remove expired snapshots. Without an expiry, the snapshots become the next source of waste.

Bulk runs often fail partway through. Deletion protection, a missing IAM permission in one account, or API throttling can each stop a run. Make every step idempotent so a rerun skips work that already finished. Report the outcome for each resource (succeeded, skipped or failed, with the reason) so a partial run does not look like a complete one.

Run the pipeline on a schedule, weekly or monthly. Idle resources then get caught soon after they appear, and engineers no longer have to repeat the same manual audit every quarter.

 +-----------+    +----------------------+    +--------------+
 |  DETECT   |--->| TAG candidate        |--->| NOTIFY owner |
 | idle IPs, |    | cleanup:delete-after |    | list + date  |
 | volumes,  |    | =YYYY-MM-DD          |    +------+-------+
 | LBs       |    +----------------------+           |
 +-----------+                                       v
       ^                                    +----------------+
       |          owner removes tag         |  GRACE PERIOD  |
       |      +-----------------------------| wait for date  |
       |      v                             +-------+--------+
       | +-----------+                              | date passed
       | | EXEMPT    |                              v
       | | (skipped) |                    +-------------------+
       | +-----------+                    | FINAL SNAPSHOT    |
       |                                  | EBS volumes only, |
       |                                  | + expiry tag      |
       |                                  +---------+---------+
       |                                            v
       |                                  +-------------------+
       |                                  | DELETE            |
       |                                  | idempotent: rerun |
       |                                  | skips done work   |
       |                                  +---------+---------+
       |                                            v
       |  +-------------------+           +-------------------+
       +--| SCHEDULER         |<----------| RECORD + REPORT   |
          | weekly / monthly; |           | id, region, acct, |
          | purges expired    |           | tags, owner, snap;|
          | final snapshots   |           | ok/skip/fail+why  |
          +-------------------+           +-------------------+

Staged cleanup pipeline: candidates are tagged and announced to their owners, held for a grace period, snapshotted if they are volumes, deleted idempotently, and recorded, with a scheduler rerunning the cycle and purging expired snapshots.

How can this save engineering time?

The money saved is the visible result, but most of the effort in a cleanup goes into finding resources and working out whose they are. Scripting the checks removes most of that effort:

  • No console clicking per region and account. The console shows one region in one account at a time. The loops above cover every enabled region in every account in a single run, so nobody has to switch views and copy IDs into a spreadsheet.
  • Owner lookup is done before anyone reads the report. Each finding already carries its account, region and owner tag, and untagged findings come with a CloudTrail query ready to run. Engineers spend their time on the few ambiguous cases, not on tracing every resource.
  • Owners decide asynchronously. The tag-and-notify step replaces meetings and message threads asking "is this yours?" An owner who needs a resource removes the tag. Silence means the resource is deleted on schedule.
  • Fewer incident investigations. Taking a final snapshot and recording every deletion means a "where did my volume go?" question can be answered from the record, and the data can be restored from the snapshot, instead of starting an investigation.
  • Faster cost-spike triage. When a bill jumps, a recent findings report quickly confirms or rules out orphaned volumes, addresses and load balancers.
  • The audit stops being a project. On a schedule, each run only surfaces what appeared since the last one, so the review stays small instead of becoming a quarterly backlog.

Illustrative estimate (assumed numbers, not a measurement): assume an organization with 8 accounts, each using 4 regions, and assume a manual console check of addresses, volumes, snapshots and load balancers takes 15 minutes per account-region pair. That is 8 × 4 × 15 = 480 minutes, or 8 hours per audit, before any owner lookup. If the scripted scan runs unattended and reviewing its report takes an assumed 1 hour, each audit saves about 7 hours. Run monthly, that is roughly 84 hours a year under these assumptions. Substitute your own account count, region count and per-check time. The scripts take time to build and maintain, so count that against the savings.

When should you avoid deleting an idle resource?

Some resources look like waste in a report but are doing their job, or have an owner other than you. Check for these cases before anything enters the deletion stage.

Allowlisted Elastic IPs

Treat releasing an Elastic IP as irreversible. AWS may let you recover a released address, but only if no other account has allocated it in the meantime, so you can't plan on getting it back. If a partner's firewall, a customer's egress rule or a payment processor allowlists that address, releasing it causes an outage in a system you don't control and may not be able to see. The few cents an hour in Elastic IP charges are cheap insurance. Tag every retained IP with the reason it's kept and who depends on it, so the next audit doesn't raise the same question.

Idle isn't the same as unused

A disaster-recovery standby load balancer, a quarter-end batch endpoint and a volume detached during a maintenance window all show zero traffic in a two-week metrics window. Look back across a full business cycle and check tags and runbooks before you mark these as waste.

IaC-managed resources

If Terraform or CloudFormation owns a resource, deleting it in the console creates drift. The next apply may recreate it, or it may fail partway through. Remove the resource from the code first, then let the tool destroy it.

Kubernetes-provisioned resources

Delete the Service or PersistentVolumeClaim inside the cluster, not the load balancer or EBS volume in AWS. If you delete them in AWS, the controller may recreate the load balancer, or the PersistentVolume is left pointing at a volume that no longer exists.

What are the alternatives, and how much does the cleanup actually save?

AWS has its own tooling for this job. Cost Explorer shows where money goes by service and usage type, so idle-address and volume spend shows up as line items. It does not tell you which specific resource is idle. Trusted Advisor, where your support plan includes the relevant checks, flags idle load balancers, unassociated Elastic IPs and underused EBS volumes. Its thresholds are fixed, though, and it does not know about your tags or your Kubernetes ownership. Use both to cross-check your script. If Trusted Advisor flags something your script missed, your filters have a gap.

Approach Coverage Effort Risk
Custom detection script Whatever you code: all regions and accounts, owner tags High to build, moderate to maintain Low if report-only
Cost Explorer Spend by service and usage type, not individual resources Low None (read-only)
Trusted Advisor Fixed checks, depends on support plan Low None (read-only)
Automated deletion Same as the script Moderate Highest: production outage

The cheapest cleanup is the waste that never gets created. Three habits help:

  • Set delete-on-termination on volumes that hold no state.
  • Require owner tags through policy.
  • Run detection on a schedule instead of during an annual sweep.

Illustrative estimate (assumed numbers, not a benchmark):

Monthly savings = (idle IPs × IP rate) + (idle GB × volume rate) + (idle LBs × LB rate)

Assume 20 IPs at $4, 2,000 GB at $0.08 and 3 load balancers at $18:

20 × 4 + 2,000 × 0.08 + 3 × 18 = $294 per month

On a bill dominated by oversized databases, that amount is small. Rank cleanup by dollars, not by how many resources you find. Automated deletion keeps those savings coming each month, but a single wrongly deleted production volume costs more than years of those savings.

How OneEnv can help

Disclosure: OneEnv is the product behind this blog.

OneEnv (oneenv.io) is a workspace-based governance platform for the things services share — environment variables, database structure, API routes and validation rules. A change to a shared value is staged on a branch, reviewed once, and then every affected service explicitly approves or rejects it before it goes live, so you can see who a change touches before it ships instead of finding out in production.

Applied to find unused aws resources, this is where it helps:

Saves time

  • Every service that inherits a shared value is listed in one place, so nobody searches repos and chats to find out who is affected.
  • One review per branch replaces coordinating each team separately; each service still keeps its own approve/reject.
  • Changing a shared variable is one edit and one review instead of editing every service's .env by hand.

Saves cost

  • Fewer production incidents and rollbacks caused by a shared value, route or column changing under a consumer unannounced.
  • Less duplicated configuration to maintain: one shared definition inherited by many services.
  • A wrong or stale value is caught at review time by the services it affects, not by a failed deploy.
  • OneEnv has a free plan (1 workspace, unlimited services and members, full governance), so trying it costs nothing.

These are qualitative benefits, not measured results — how much you save depends on how many services share the value.

Want to try it? Start at oneenv.io.