Last active
December 22, 2021 09:17
-
-
Save jaytaylor/f36e24fab4a6dba6823099699c97aa1a to your computer and use it in GitHub Desktop.
AWS EC2 AMI-ID finder for Ubuntu 16.04 Xenial.
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
#!/usr/bin/env bash | |
## | |
# Description | |
# | |
# AWS EC2 AMI-ID finder for Ubuntu 16.04 Xenial. | |
# | |
set -o errexit | |
set -o pipefail | |
set -o nounset | |
set -x | |
aws ec2 \ | |
--region ap-southeast-2 describe-images \ | |
--filters \ | |
'Name=architecture,Values=x86_64' \ | |
'Name=root-device-type,Values=ebs' \ | |
'Name=state,Values=available' \ | |
'Name=virtualization-type,Values=hvm' \ | |
'Name=image-type,Values=machine' \ | |
'Name=name,Values=ubuntu/images/hvm-ssd/*16.04*' \ | |
--query 'Images[*].{ImageId:ImageId,Name:Name}' \ | |
| jq 'map(select(.Name | test("-server-[0-9]{8}$"))) | sort_by(.Name) | reverse | .[0].ImageId'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also see: