Created
December 5, 2017 16:08
-
-
Save jeremy-donson/dd96148b07207ebd3b3a8042165cba5d to your computer and use it in GitHub Desktop.
BASH SCRIPT: Queries AWS for the *latest* AMI images per global region, writes them to a file, and then reads that file back to us.
This file contains 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 | |
# This queries AWS for the *latest* AMI images per global region, writes them to a file, and then reads that file back to us. | |
for REGION in $(aws ec2 describe-regions --query "Regions[].RegionName" --output json | jq -r '.[]'); | |
do | |
echo "$region = $(aws ec2 describe-images --owners amazon \ | |
--filters 'Name=name,Values=amzn-ami-hvm-????.??.?.x86_64-gp2'\ | |
--query 'sort_by(Images, &CreationDate) | [-1].ImageId' --region $REGION)"; | |
done > ~/aws-latest-images-per-region.txt | |
cat ~/aws-latest-images-per-region.txt | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment