Created
September 3, 2021 11:16
-
-
Save toabctl/fc43173c06cc412179580a6d831a4f91 to your computer and use it in GitHub Desktop.
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
$ cat aws-images.sh | |
#!/bin/bash | |
OUTFILE=out.txt | |
AWS_REGIONS=(ap-east-1 ap-northeast-1 ap-northeast-2 ap-northeast-3 ap-south-1 ap-southeast-1 ap-southeast-2 af-south-1 ca-central-1 cn-north-1 cn-northwest-1 eu-central-1 eu-north-1 eu-west-1 eu-west-2 eu-west-3 eu-south-1 sa-east-1 me-south-1 us-east-1 us-east-2 us-gov-west-1 us-gov-east-1 us-west-1 us-west-2) | |
for region in ${AWS_REGIONS[@]}; do | |
export AWS_DEFAULT_REGION=$region | |
echo "Getting images for region $region ..." | |
aws ec2 describe-images --owner 099720109477 --query 'Images[?Name!=`null`]|[? (starts_with(Name, `ubuntu/images/`) == `true`) || (starts_with(Name, `ubuntu-minimal/images/`) == `true`) || (starts_with(Name, `ubuntu-eks/`) == `true`)]|[? (contains(Name, `precise`) == `false`) && (contains(Name, `quantal`) == `false`) && (contains(Name, `raring`) == `false`) && (contains(Name, `saucy`) == `false`) && (contains(Name, `trusty`) == `false`) && (contains(Name, `utopic`) == `false`) && (contains(Name, `vivid`) == `false`) && (contains(Name, `wily`) == `false`) && (contains(Name, `yakkety`) == `false`) && (contains(Name, `zesty`) == `false`) && (contains(Name, `artful`) == `false`) && (contains(Name, `cosmic`) == `false`) && (contains(Name, `disco`) == `false`) && (contains(Name, `eoan`) == `false`) && (contains(Name, `groovy`) == `false`)].[CreationDate,ImageId,Architecture,Name]' --output text | sort >> $OUTFILE | |
done | |
echo "All images collected in $OUTFILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment