Skip to content

Instantly share code, notes, and snippets.

@nmarley
Created April 16, 2017 02:54
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 nmarley/1b6afcabd25c91a892d20c3566dbb051 to your computer and use it in GitHub Desktop.
Save nmarley/1b6afcabd25c91a892d20c3566dbb051 to your computer and use it in GitHub Desktop.
Query AWS for specific Ubuntu image (AMI-ID), can be run against any region
#! /bin/bash
# get Ubuntu 16.04 AMI for default region
aws ec2 describe-images --filters Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20170221 | jq -r '.Images[].ImageId'
# get same image AMI for ca-central-1
aws --region ca-central-1 ec2 describe-images --filters Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20170221 | jq -r '.Images[].ImageId'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment