Skip to content

Instantly share code, notes, and snippets.

@dsmrt
Created August 2, 2018 15:52
Show Gist options
  • Select an option

  • Save dsmrt/6936d2c4aaa1e54a3d62a041856d5a77 to your computer and use it in GitHub Desktop.

Select an option

Save dsmrt/6936d2c4aaa1e54a3d62a041856d5a77 to your computer and use it in GitHub Desktop.
Get the latest recommended ECS optimized AMIs printed for CloudFormation Mappings
#!/bin/bash
echo "AWSRegionToAMI:"
for region in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text)
do
echo " ${region}:";
AMI=$(aws ssm get-parameters --names /aws/service/ecs/optimized-ami/amazon-linux/recommended --region $region | jq -r '.Parameters[0].Value | fromjson | .image_id')
printf " AMI: %s \n" $AMI
done
@dsmrt
Copy link
Copy Markdown
Author

dsmrt commented Feb 12, 2019

No longer need to do this. You can now use the ssm parameter as a CloudFormation parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment