-
-
Save denzfarid/74ee8912b28996c7c96415bf991944e1 to your computer and use it in GitHub Desktop.
Find un-used AMIs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash -e | |
| set -o pipefail | |
| # File 1 is the list of our AMIs | |
| # File 2 is the list of AMIs used by our instances | |
| # Column 1 is an image of ours that is not in use | |
| # Column 2 is an AMI that is in use that isn't one of ours | |
| # Column 3 is the list of our AMIs that are in use. | |
| comm -23 \ | |
| <(aws ec2 describe-images --owners self | jq -r ' [.Images[].ImageId] | sort | unique | .[]') \ | |
| <(aws ec2 describe-instances | jq -r '[.Reservations[].Instances[].ImageId] | sort | unique | .[]') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment