Created
August 15, 2017 07:20
-
-
Save ksatirli/7bcda64be054c10b2ef559f94e3408dc to your computer and use it in GitHub Desktop.
AWS: get AMI IDs
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/bash | |
aws \ | |
ec2 describe-images \ | |
--owner "self" \ | |
--filter "Name=root-device-type,Values=ebs" \ | |
--filter "Name=hypervisor,Values=xen" \ | |
--filter "Name=state,Values=available" \ | |
--filter "Name=architecture,Values=x86_64" \ | |
--filter "Name=public,Values=true" \ | |
--filter "Name=image-type,Values=machine" \ | |
--filters "Name=name,Values=cultivatedops-base-*" \ | |
| \ | |
jq \ | |
--sort-keys \ | |
".Images | sort_by(.CreationDate) | reverse | .[0] | { ImageId } | .ImageId" |
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/bash | |
aws \ | |
ec2 \ | |
describe-images \ | |
--owner "amazon" \ | |
--filter "Name=root-device-type,Values=ebs" \ | |
--filter "Name=hypervisor,Values=xen" \ | |
--filter "Name=state,Values=available" \ | |
--filter "Name=architecture,Values=x86_64" \ | |
--filter "Name=public,Values=true" \ | |
--filter "Name=image-type,Values=machine" \ | |
--filter "Name=description,Values=Amazon Linux AMI 2016.03.0 x86_64 minimal PV EBS" \ | |
| jq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment