Skip to content

Instantly share code, notes, and snippets.

@jpignata
Last active March 24, 2018 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jpignata/990c9bd3a7d6a4fd93b1be20bd7a0776 to your computer and use it in GitHub Desktop.
Save jpignata/990c9bd3a7d6a4fd93b1be20bd7a0776 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