Remove old EBS volumes

Rationale TL;DR

You deployed Kubernetes on AWS and you want to remove the old EBS volumes there

The solution

So you deployed K8S on AWS (Kops or EKS) and you start to see EBS volumes not attached. That is money you can save. However, you don’t want to go to the AWS console (who wants) to check those volumes, instead you want some script that would allow you to find those volumes and delete them.

aws ec2 describe-volumes --filters Name=status,Values=available | jq '.Volumes[].VolumeId' -r | xargs -L 1 -I VOLUME aws ec2 delete-volume --volume-id VOLUME

This would find any volume whose status is available. The jq command gets the volume ids and the xargs would use those ids and remove those volumes.