All examples for AWS Resource Cleanup Runbook

Safe EBS Volume Cleanup

Step-by-step guide to safely delete 8 unattached EBS volumes with pre-deletion snapshots, safety checklist, deletion commands, and rollback procedures. Estimated savings: $468-540/year.

Input

What you provide to the skill

I found 8 unattached EBS volumes totaling 300GB. How do I safely delete them without breaking anything?

Output

What the skill generates for you

Safe EBS Volume Cleanup

Your Situation

  • 8 unattached volumes
  • Total: 300GB
  • Current monthly cost: ~$24 (gp3) or ~$30 (gp2)
  • Annual savings: ~$288-360

Pre-Deletion Safety Checklist

For each volume, verify:

  1. Status is ‘available’ (unattached)
  2. No recent attachments (not temporarily detached)
  3. Tags don’t indicate importance (check for “backup”, “prod”, “critical”)
  4. Not referenced elsewhere (launch templates, AMIs)

Get full volume details:

aws ec2 describe-volumes \
--volume-ids vol-xxxxx vol-yyyyy vol-zzzzz \
--query 'Volumes[*].{ID:VolumeId,Size:Size,Type:VolumeType,Created:CreateTime,Name:Tags[?Key==`Name`].Value|[0],State:State,Attachments:Attachments}' \
--output json

Replace vol-xxxxx vol-yyyyy vol-zzzzz with your actual volume IDs.

Safety Step: Create Snapshots First

Before deleting, create snapshots as insurance:

# Create snapshot of each volume
for vol in vol-xxxxx vol-yyyyy vol-zzzzz; do
aws ec2 create-snapshot \
--volume-id $vol \
--description "Pre-deletion backup - safe to delete after 30 days" \
--tag-specifications 'ResourceType=snapshot,Tags=[{Key=Purpose,Value=PreDeletionBackup},{Key=DeleteAfter,Value=2025-02-15}]'
done

Snapshot cost: $0.05/GB/month × 300GB = $15/month

Keep snapshots for 30 days, then delete them too.

Deletion Commands

Test with one volume first:

aws ec2 delete-volume --volume-id vol-xxxxx

If successful, delete the rest:

# List your volume IDs
volumes="vol-xxxxx vol-yyyyy vol-zzzzz vol-aaaaa vol-bbbbb vol-ccccc vol-ddddd vol-eeeee"
for vol in $volumes; do
echo "Deleting $vol..."
aws ec2 delete-volume --volume-id $vol
if [ $? -eq 0 ]; then
echo "✓ Deleted $vol"
else
echo "✗ Failed to delete $vol"
fi
done

Verify Deletion

aws ec2 describe-volumes \
--volume-ids vol-xxxxx vol-yyyyy vol-zzzzz \
--query 'Volumes[*].[VolumeId,State]'

Should return empty or show states as “deleting”.

Rollback Plan

If you accidentally deleted a needed volume:

  1. Find your snapshot:
aws ec2 describe-snapshots \
--owner-ids self \
--filters Name=tag:Purpose,Values=PreDeletionBackup \
--query 'Snapshots[*].[SnapshotId,Description,StartTime]' \
--output table
  1. Create volume from snapshot:
aws ec2 create-volume \
--snapshot-id snap-xxxxx \
--availability-zone us-east-1a \
--volume-type gp3 \
--tag-specifications 'ResourceType=volume,Tags=[{Key=Name,Value=Restored-from-snapshot}]'
  1. Attach to instance (if needed):
aws ec2 attach-volume \
--volume-id vol-newvolid \
--instance-id i-xxxxx \
--device /dev/sdf

Delete Snapshots After 30 Days

Once you’re confident volumes won’t be needed:

# Find pre-deletion snapshots
aws ec2 describe-snapshots \
--owner-ids self \
--filters Name=tag:Purpose,Values=PreDeletionBackup \
--query 'Snapshots[*].SnapshotId' \
--output text | while read snap; do
aws ec2 delete-snapshot --snapshot-id $snap
done

Additional monthly savings: $15/month
Total annual savings: $288-360 (volumes) + $180 (snapshots after 30 days) = $468-540/year