#!/bin/sh | |
# Use AWS CLI to get the most recent version of an AMI that | |
# matches certain criteria. Has obvious uses. Made possible via | |
# --query, --output text, and the fact that RFC3339 datetime | |
# fields are easily sortable. | |
export AWS_DEFAULT_REGION=us-east-1 | |
aws ec2 describe-images \ | |
--filters Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64* \ | |
--query 'Images[*].[ImageId,CreationDate]' --output text \ | |
| sort -k2 -r \ | |
| head -n1 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
jamesonwilliams
commented
Mar 19, 2017
Nice! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
arpat
commented
Sep 28, 2017
Thanks! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
visokoo
commented
Oct 2, 2017
You're awesome, thank you! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
blckct
commented
Mar 28, 2018
Piping it to |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice!