Skip to content

Instantly share code, notes, and snippets.

@daniyel
Created July 4, 2018 11:56
Show Gist options
  • Save daniyel/9109817b07deea29faaf8fc59ef1484c to your computer and use it in GitHub Desktop.
Save daniyel/9109817b07deea29faaf8fc59ef1484c to your computer and use it in GitHub Desktop.
Get a list of AMI images for CloudFormation use.
#!/bin/bash -xe
REGIONS=$(aws ec2 describe-regions --query "Regions[].RegionName" --output text)
for region in $REGIONS; do
ami=$(aws --region $region ec2 describe-images --filters "Name=name,Values=amzn-ami-hvm-2018.03.0.20180508-x86_64-gp2" --query "Images[0].ImageId" --output "text")
printf "$region:\n AMI: '$ami'\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment