AWS:AMIで利用してないスナップショットを探して削除する

  1. 自分が所有するAMIの一覧を取得
aws ec2 describe-images --owners self | jq '.Images[] | {ImageId}' | jq '.[]'| sed 's/"//g'
  1. 自分が所有するAMIのスナップショットIDの取得
aws ec2 describe-images --owners self | jq '.Images[]["BlockDeviceMappings"][]["Ebs"]["SnapshotId"]' | sed 's/"//g'
  1. 自分が所有するスナップショットのIDの取得
aws ec2 describe-snapshots --owner-ids あなたのID | jq '.Snapshots[] .SnapshotId' | sed 's/"//g'
  1. スナップショットの削除

2と3の結果を比較すると、AMIで利用されてないスナップショットを出せますので、それに対して:

aws ec2 delete-snapshot --snapshot-id スナップショットID

なお、最後にステータスがavailableのvolumeを削除する