Skip to content

Instantly share code, notes, and snippets.

@jwdeane
Created May 22, 2018 02:48
Show Gist options
  • Save jwdeane/2f6df088ba916f1ca7ffd2cb0b6944e7 to your computer and use it in GitHub Desktop.
Save jwdeane/2f6df088ba916f1ca7ffd2cb0b6944e7 to your computer and use it in GitHub Desktop.
Get latest AWS EC2 Linux AMI
#!/bin/bash
# Assumes AWS CLI installed and configured with default region.
# To query an alternate region add the --region parameter, e.g.
# --region us-west-2
aws ec2 describe-images \
--owners amazon \
--filters "Name=name,Values=amzn-ami-hvm*ebs" \
--query 'sort_by(Images,&CreationDate)[-1].ImageId' \
--output text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment