Why do orphaned EBS volumes, snapshots and Elastic IPs keep appearing?
An orphaned resource is one that still exists and still bills, but no longer serves a workload. For EBS and Elastic IPs, orphans rarely come from carelessness. They come from AWS defaults that favor keeping data over deleting it.
- Volumes attached after launch default to
DeleteOnTermination=false, so terminating the instance leaves them in theavailablestate. - Root volumes can be created with
DeleteOnTermination=falsein a launch template or block device mapping, often to protect data during debugging. The setting outlives its purpose. - Deregistering an AMI does not delete the snapshots behind it.
- Elastic IPs stay allocated to the account after their instance terminates, because a stable address is the reason they exist.
- Failed IaC applies and autoscaling churn can create volumes or allocate addresses, then lose track of them when a run errors out midway or state drifts.
The map from workflow to leftover:
- Attach data volume, terminate instance → unattached EBS volume
- Bake AMI, later deregister it → orphaned snapshots
- Allocate EIP, terminate instance → unattached Elastic IP
- Partial IaC apply or scale-in → untracked volumes, snapshots, IPs
None of these shows up as an error. EBS volumes are billed on provisioned size whether or not they are attached. Snapshots are billed on stored data, and idle public IPv4 addresses are billed too. The cost accumulates without any alert.
In shared accounts, the team that created a resource has often moved on. Backend and platform engineers who run those accounts are the practical owners, because they have the access and the context to judge what is safe to remove.
WORKFLOW ORPHAN LEFT BEHIND
+-------------------------------+ +------------------------------+
| Data volume attached after | | Unattached EBS volume |
| launch, or root volume with | | state: available |
| DeleteOnTermination=false; |------->| billed on provisioned size |
| then terminate instance | | |
+-------------------------------+ +------------------------------+
+-------------------------------+ +------------------------------+
| Bake AMI, later deregister |------->| Orphaned EBS snapshots |
| the AMI | | billed on stored data |
+-------------------------------+ +------------------------------+
+-------------------------------+ +------------------------------+
| Allocate EIP, then terminate |------->| Unattached Elastic IP |
| the instance | | billed as idle public IPv4 |
+-------------------------------+ +------------------------------+
+-------------------------------+ +------------------------------+
| Failed IaC apply, state drift |------->| Untracked volumes, |
| or autoscaling scale-in | | snapshots and Elastic IPs |
+-------------------------------+ +------------------------------+
|
v
+------------------------------+
| No error, no alert: cost |
| accrues until platform and |
| backend owners clean up |
+------------------------------+
Routine workflows such as terminating instances, deregistering AMIs, releasing nothing after EIP use, and partial IaC or scale-in runs each leave a specific billable orphan that raises no error.
How do you find unattached EBS volumes in every region and account?
Start with the state filter. A volume that is not attached to any instance reports the status available, so aws ec2 describe-volumes with a filter of Name=status,Values=available returns exactly the candidates. The catch is that the call is regional. Run it once against your default region and a clean result tells you nothing about the other regions, or about any other account in your organization. That scan gives false confidence. Orphans tend to pile up in places nobody checks: a region used once for a migration test, or a sandbox account that was set up and then forgotten.
To cover everything, get the list of enabled regions from aws ec2 describe-regions and loop the volume query over each one. Then repeat that loop inside every account. In practice you assume a read-only role in each member account with aws sts assume-role and use the temporary credentials it returns for that account's scan.
Triage checklist
Do not delete a volume just because it is available. Check it first:
- Creation time. A volume created yesterday may belong to a deployment that is still in progress. A volume detached for months is a stronger candidate.
- Tags. Owner, service or ticket tags tell you who to ask. Volumes with no tags at all usually need the most investigation.
- Last attachment context. Search CloudTrail for
AttachVolumeandDetachVolumeevents on the volume ID to see which instance it was attached to and who detached it. CloudTrail event history only goes back 90 days unless you keep a trail, so older context may be gone. - Size and type. These determine cost. Sort by provisioned GiB, and flag io1 and io2 volumes because you also pay for their provisioned IOPS. Investigate the largest and most expensive volumes first.
#!/usr/bin/env bash
# Scan every enabled region in every listed account for unattached (available) EBS volumes.
set -euo pipefail
# Placeholder account IDs and a read-only role that exists in each member account.
ACCOUNTS=("111111111111" "222222222222")
ROLE_NAME="EbsAuditReadOnly"
for ACCOUNT in "${ACCOUNTS[@]}"; do
# Assume the audit role and capture temporary credentials for this account only.
read -r AK SK ST < <(aws sts assume-role \
--role-arn "arn:aws:iam::${ACCOUNT}:role/${ROLE_NAME}" \
--role-session-name ebs-orphan-scan \
--query 'Credentials.[AccessKeyId,SecretAccessKey,SessionToken]' \
--output text)
# Enabled regions only (describe-regions omits opt-in regions that are not enabled).
REGIONS=$(AWS_ACCESS_KEY_ID=$AK AWS_SECRET_ACCESS_KEY=$SK AWS_SESSION_TOKEN=$ST \
aws ec2 describe-regions --query 'Regions[].RegionName' --output text)
for REGION in $REGIONS; do
# List triage fields: ID, size, type, IOPS, creation time, and tag count.
AWS_ACCESS_KEY_ID=$AK AWS_SECRET_ACCESS_KEY=$SK AWS_SESSION_TOKEN=$ST \
aws ec2 describe-volumes \
--region "$REGION" \
--filters Name=status,Values=available \
--query 'Volumes[].[VolumeId,Size,VolumeType,Iops,CreateTime,length(Tags || `[]`)]' \
--output text |
while read -r VOL SIZE TYPE IOPS CREATED TAGS; do
echo -e "${ACCOUNT}\t${REGION}\t${VOL}\t${SIZE}\t${TYPE}\t${IOPS}\t${CREATED}\t${TAGS}"
done
done
done | sort -t$'\t' -k4,4nr # Largest provisioned GiB first, so big volumes get investigated first.
A bash loop that assumes a read-only role in each account, iterates over every enabled region, lists EBS volumes in the available state with their size, type, IOPS, creation time and tag count, and sorts the results by size so the largest candidates are triaged first.
How do you identify old EBS snapshots that are safe to delete?
Snapshots outlive their volumes by design, so a missing parent volume does not mean a snapshot is unused. Start by listing only the snapshots your account owns with aws ec2 describe-snapshots --owner-ids self. Without that filter, the call also returns public and shared snapshots, which you cannot delete. Then run each snapshot through the checks below before age becomes relevant.
| Check | How to verify | If true |
|---|---|---|
| Referenced by an AMI | Search describe-images --owners self block device mappings for the snapshot ID |
Deregister the AMI first, or keep the snapshot. EC2 rejects the delete while the AMI is registered. |
| Managed by Data Lifecycle Manager | aws:dlm:lifecycle-policy-id tag |
Adjust the policy's retention instead of deleting by hand. |
| Managed by AWS Backup | aws:backup:source-resource tag or a description naming AWS Backup |
Delete through the backup vault so recovery points stay consistent. |
| Source volume still exists | describe-volumes on the snapshot's VolumeId |
The snapshot is likely part of an active backup chain. Review it with the volume owner. |
Exclusion tags such as legal-hold, compliance-retention or golden-image must be evaluated before any "older than N days" rule. A legal hold or audit requirement is often the reason an old snapshot exists, so age-first logic deletes exactly the snapshots you are obligated to keep. Treat a matching tag as a hard stop that no age threshold can override.
Expect savings estimates to be imprecise. EBS snapshots are incremental. Deleting one frees only the blocks that no other snapshot references, and AWS carries any shared blocks forward to later snapshots. A snapshot that reports 500 GiB might free almost nothing. Compare billed snapshot storage before and after cleanup, not the sum of the volume sizes.
#!/usr/bin/env bash
# Read-only triage of owned EBS snapshots. Prints a verdict per snapshot; deletes nothing.
set -euo pipefail
MAX_AGE_DAYS=180 # placeholder age threshold, applied only after every other check
CUTOFF=$(date -u -d "-${MAX_AGE_DAYS} days" +%Y-%m-%dT%H:%M:%S)
EXCLUDE_RE=',(legal-hold|compliance-retention|golden-image),'
# Every snapshot ID referenced by an AMI this account owns
AMI_SNAPS=$(aws ec2 describe-images --owners self \
--query 'Images[].BlockDeviceMappings[].Ebs.SnapshotId' --output text)
# --owner-ids self excludes public and shared snapshots you cannot delete
aws ec2 describe-snapshots --owner-ids self \
--query 'Snapshots[].[SnapshotId,VolumeId,StartTime,join(`,`, Tags[].Key || `[]`)]' \
--output text |
while IFS=$'\t' read -r SNAP VOL START TAGKEYS; do
KEYS=",${TAGKEYS:-},"
# Hard stop: exclusion tags win over every rule below, including age
if [[ "$KEYS" =~ $EXCLUDE_RE ]]; then echo "$SNAP KEEP exclusion-tag"; continue; fi
# An AMI still uses it: EC2 rejects the delete until the AMI is deregistered
if grep -qw -- "$SNAP" <<<"$AMI_SNAPS"; then echo "$SNAP KEEP referenced-by-ami"; continue; fi
# Lifecycle-managed: change DLM retention or delete via the AWS Backup vault instead
if [[ "$KEYS" == *,aws:dlm:lifecycle-policy-id,* ]]; then echo "$SNAP SKIP managed-by-dlm"; continue; fi
if [[ "$KEYS" == *,aws:backup:source-resource,* ]]; then echo "$SNAP SKIP managed-by-aws-backup"; continue; fi
# Source volume still exists: likely part of an active backup chain
if [[ "$VOL" != "None" && "$VOL" != "vol-ffffffff" ]] &&
aws ec2 describe-volumes --volume-ids "$VOL" </dev/null >/dev/null 2>&1; then
echo "$SNAP REVIEW source-volume-exists:$VOL"; continue
fi
# Only now does age matter (ISO 8601 timestamps compare correctly as strings)
if [[ "$START" < "$CUTOFF" ]]; then echo "$SNAP CANDIDATE older-than-${MAX_AGE_DAYS}d"
else echo "$SNAP KEEP too-recent"; fi
done
A read-only bash report that runs each self-owned snapshot through exclusion-tag, AMI, DLM, AWS Backup and source-volume checks before the age rule, and only then flags it as a deletion candidate.
How do you find unattached Elastic IPs, and when should you avoid releasing them?
Elastic IPs are regional, so query each region you use. Run aws ec2 describe-addresses and filter for entries with no AssociationId. An address with an AssociationId is attached to an instance, network interface or NAT gateway. One without it is allocated to your account but routes nowhere. To keep the output useful, include PublicIp, AllocationId and Tags.
AWS bills for public IPv4 addresses, and an idle Elastic IP is charged the same way as one in use. Each idle address costs little, but they accumulate across regions and accounts. Unassociated is not the only signal of waste: an address attached to an instance that has been stopped for months is also paying for nothing.
Why releasing is the risky step
Releasing an address returns it to AWS's pool. You may be able to reallocate the same IP shortly afterward, but that is not guaranteed. Once another customer receives it, it is gone. Fixed IPs are usually kept because something outside AWS depends on them, such as a partner's firewall rule, a customer allowlist, an SPF record or a DNS A record. When those break, the failure appears in someone else's logs, often days later.
Checks before release
- Search your DNS zones and SPF records for the IP.
- Search infrastructure-as-code repositories and runbooks for both the IP and the allocation ID.
- Look up the
AllocateAddressevent in CloudTrail to see who allocated it, if the event falls within your retention window. Then ask that person or team. - Ask the teams who own partner integrations whether the IP is on an external allowlist.
- Tag the address as a release candidate and wait through a full business cycle before releasing it.
#!/usr/bin/env bash
# Report unassociated Elastic IPs in every enabled region, then run read-only
# pre-release checks. Nothing here releases an address.
set -euo pipefail
for region in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do
# No AssociationId means the address is allocated to the account but routes nowhere.
aws ec2 describe-addresses --region "$region" \
--query 'Addresses[?AssociationId==null].{Region:`'"$region"'`,Ip:PublicIp,Alloc:AllocationId,Tags:Tags}' \
--output json
done
# --- Checks for one candidate (placeholder values) ---
REGION="eu-west-1"
IP="203.0.113.25"
ALLOC="eipalloc-0abc123def4567890"
# 1. Look for the IP or allocation ID in IaC repos and runbooks.
grep -rnF -e "$IP" -e "$ALLOC" ./infra ./runbooks || echo "no references found in repos"
# 2. Check the public DNS records you know about. This does not search every zone or SPF record.
dig +short TXT example.com | grep -F "$IP" || echo "not in example.com TXT/SPF"
# 3. Find who allocated it. This only works if the event falls within CloudTrail event history retention.
aws cloudtrail lookup-events --region "$REGION" \
--lookup-attributes AttributeKey=EventName,AttributeValue=AllocateAddress \
--query 'Events[].{Time:EventTime,User:Username,Resources:Resources}' \
--output json
# 4. Mark it as a release candidate and wait a full business cycle before releasing.
aws ec2 create-tags --region "$REGION" --resources "$ALLOC" \
--tags Key=cleanup-status,Value=release-candidate Key=cleanup-flagged-on,Value="$(date +%F)"
A read-only script that lists Elastic IPs with no AssociationId in every enabled region, runs pre-release checks against one candidate address, and tags it for a delayed release.
What does a safe deletion workflow look like?
Deleting an EBS volume or snapshot is irreversible. There is no recycle step unless you set one up beforehand. A volume that looks orphaned may be a database disk someone detached on purpose, kept for point-in-time recovery or held for a security investigation. Its owner may not have tagged it. The workflow below is designed so that a wrong guess costs a few days of storage, not lost data.
- Tag the resource as a cleanup candidate. Record the detection date and the reason, such as "unattached for 30 days". This makes the decision visible and searchable.
- Notify the owner. Use the owner tag, CloudTrail history or account mapping from earlier. If you can't find an owner, escalate. Silence is not consent.
- Wait through a grace period. It should be long enough to cover holidays and on-call rotations. Anyone can remove the tag to veto the deletion.
- Take a final snapshot of each volume and tag it with an expiry date.
- Delete the resource.
- Delete the final snapshot when its retention window ends. Otherwise the cleanup just creates the next batch of old snapshots.
Start with report-only automation. At first, the tooling should only list candidates, and a human approves each deletion batch. That limits the blast radius while you tune the detection rules.
Split IAM into two roles:
- Audit role: read-only
Describe*permissions across all accounts. - Deletion role: a separate role that can delete only resources carrying the cleanup tag, enforced through resource-tag conditions.
Before any real run, exercise the deletion role with --dry-run. DeleteVolume, DeleteSnapshot and ReleaseAddress support it, so you can confirm permissions and targets without changing anything.
How much does idle EBS and IP waste cost, and is cleanup worth the engineering time?
Once the workflow is safe, decide where to spend effort. Start with your own inventory and plug your numbers into one formula:
Monthly waste = (unattached GB × volume rate) + (orphaned snapshot GB × snapshot rate) + (idle IPs × hourly IP rate × 730)
Illustrative estimate (assumed numbers, not a benchmark): Assume 40 unattached volumes averaging 100 GB at $0.08 per GB-month, 2,000 GB of orphaned snapshots at $0.05 per GB-month, and 10 idle Elastic IPs at $0.005 per hour.
- Volumes: 40 × 100 × 0.08 = $320
- Snapshots: 2,000 × 0.05 = $100
- IPs: 10 × 0.005 × 730 = $36.50
- Total: about $456 per month
Rates vary by region, volume type and snapshot tier, so replace these with figures from your own pricing page or bill.
Investigation also costs money. Take a 10 GB volume with no tags and no clear owner. At the assumed rate it costs $0.80 a month. If you assume 30 minutes of engineer time at $100 an hour, the investigation costs $50, which is roughly five years of storage. For small, ambiguous items, tagging them with an expiry date and letting the next scheduled run handle them is cheaper than tracking down an owner. Spend investigation time on the large items first.
The bigger savings come from not repeating discovery work:
| Aspect | Periodic manual purge | Repeatable checklist |
|---|---|---|
| Discovery | Ad-hoc console or CLI searches | Same queries run on a schedule |
| Ownership questions | Re-asked every purge | Answered once through tags |
| Ambiguous items | Re-investigated every time | Expiry tag, then automatic decision |
| Risk of wrong deletion | Depends on who runs it | Dry run and snapshot-before-delete every time |
| Effort trend | Flat or rising | Falls as tagging coverage improves |
How do you prevent new orphans, and what are the alternatives to manual cleanup?
Prevention works by recording, at creation time, the context that cleanup otherwise has to reconstruct later.
- Owner and expiry tags enforced in IaC. Fail the pipeline when a volume, snapshot or Elastic IP lacks
ownerandexpires-on. Enforcement has to sit in CI or in organization-level policy. A tag that is merely recommended is missing exactly when you need it. - Explicit
DeleteOnTerminationin launch templates. Set it on every block device mapping rather than relying on AMI defaults. Then the volumes that survive termination are the ones someone chose to keep. - Snapshot lifecycle policies. Data Lifecycle Manager or AWS Backup should own retention, so old snapshots expire according to a written rule.
- A weekly orphan report. Post unattached and untagged resources to the owning team's channel. Owners act when they see the problem regularly.
| Approach | Strength | Trade-off | Fits |
|---|---|---|---|
| One-off purge | Fast visible savings | Orphans return within months | Teams with no tagging yet |
| Weekly report plus enforced tags | Low risk, builds ownership | Needs someone to triage the report | Most teams |
| Fully automated deletion | No ongoing effort | One bad rule destroys data | Mature tagging, tested restores |
| AWS-native reporting (Trusted Advisor, Cost Explorer) | No build cost | Flags candidates but explains nothing, takes no action | Any team, as a cross-check |
Untagged legacy resources still need manual investigation. Check CloudTrail for the creating principal, inspect volume contents from a temporary instance, and snapshot before deleting. Start new accounts with enforced tags and the weekly report. Adopt automated deletion only after tag coverage is near complete and you have tested restores.
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 orphaned ebs volumes cleanup, 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.
- The dependency graph answers "what does this touch?" in seconds instead of a manual audit.
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.
- You can size a change's blast radius before merging, avoiding surprise cross-team firefighting.
- 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.