-
-
Save LoveDuckie/d5f672a76f5f0df7fd6a93317a4173b9 to your computer and use it in GitHub Desktop.
Get latest Ubuntu AMI ID for AMD64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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*amd64* \ | |
--query 'Images[*].[ImageId,CreationDate,Description]' --output text \ | |
| sort -k2 -r \ | |
| head -n1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment