Skip to content

Instantly share code, notes, and snippets.

@prafulmehrotra
Forked from jpignata/amis.sh
Created March 24, 2018 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prafulmehrotra/6d2f8ca4d9edfe2fd7a6be3d36277451 to your computer and use it in GitHub Desktop.
Save prafulmehrotra/6d2f8ca4d9edfe2fd7a6be3d36277451 to your computer and use it in GitHub Desktop.
Build CloudFormation mappings for the latest ECS Optimized AMI for every Region for your account
echo "AWSRegionToAMI:"
for region in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text)
do
echo " ${region}:"
echo -n " AMI: "
aws ec2 describe-images \
--owners amazon \
--query 'reverse(sort_by(Images[?Name != `null`] | [?contains(Name, `amazon-ecs-optimized`) == `true`], &CreationDate))[:1].ImageId' \
--output text \
--region $region
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment