Created
October 13, 2017 23:09
-
-
Save drmikecrowe/4ca45170f5c0b072c1438837150ad81d to your computer and use it in GitHub Desktop.
Search for the latest releases for a given search string. Assumes that vendors release in bulk, so it looks for over 2 images released in a day and shows those matches
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 | |
LINES=6 | |
if [ $# -ne 1 ];then | |
echo "Usage:" | |
echo " $0 keyword" | |
exit 1 | |
fi | |
# REGION=us-east-1 | |
# aws ec2 describe-images --region $REGION --query "Images[*].[CreationDate]" --filters "Name=name,Values=*$1*" --output text | cut -b -10 | sort -k1 -r | uniq -c | awk '{ if ($1 > 1) print $2 }' | sort -r | head -n 1 | |
# exit 1 | |
REGIONS="us-east-1 us-east-2 us-west-1 us-west-2" | |
for REGION in $REGIONS; do | |
echo "$REGION: " | |
DATE=$(aws ec2 describe-images --region $REGION --query "Images[*].[CreationDate]" --filters "Name=name,Values=*$1*" --output text | cut -b -10 | sort -k1 -r | uniq -c | awk '{ if ($1 > 1) print $2 }' | sort -r | head -n 1) | |
aws ec2 describe-images \ | |
--region $REGION \ | |
--query "Images[*].[ImageId,CreationDate,Name]" \ | |
--filters "Name=name,Values=*$1*" \ | |
--output text | grep "$DATE" | |
echo " " | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output for
search-aws-amis.sh 'ubuntu*16.04'