Skip to content

Instantly share code, notes, and snippets.

@ksatirli
Created August 15, 2017 07:20
Show Gist options
  • Save ksatirli/7bcda64be054c10b2ef559f94e3408dc to your computer and use it in GitHub Desktop.
Save ksatirli/7bcda64be054c10b2ef559f94e3408dc to your computer and use it in GitHub Desktop.
AWS: get AMI IDs
#!/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"
#!/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