Browse Source

Merge pull request #407 from mdr-engineering/feature/dw_noticket_deleteamiscript

Adds helper script to delete amis and backing snapshots
Duane Waddle 4 years ago
parent
commit
24e3d70690
1 changed files with 13 additions and 0 deletions
  1. 13 0
      bin/delete-ami.sh

+ 13 - 0
bin/delete-ami.sh

@@ -0,0 +1,13 @@
+#!/bin/sh
+
+while [[ "$1" != "" ]]; do
+	SNAPS=$( aws ec2 describe-images --image-ids $1 | jq -r '.Images[].BlockDeviceMappings[].Ebs.SnapshotId' )
+
+	aws ec2 deregister-image --image-id $1
+
+	for SNAP in $SNAPS; do
+		aws ec2 delete-snapshot --snapshot-id $SNAP
+	done
+
+	shift
+done