Get AMI id and snapshot ID by tag
Get the AMI and snapshot ID for a given EC2 image using awscli and jq. For example, if we have an image that has source=packer as a tag:
$ aws ec2 describe-images --filter Name=tag:source,Values=packer | jq ".Images[0].ImageId,.Images[0].BlockDeviceMappings[0].Ebs.SnapshotId"
{
"snap": "snap-2e2d50c3",
"ami": "ami-43e0ab01"
}
Written by Lorin Hochstein
Related protips
1 Response
The AWS command-line interface has --query
which you can use instead of jq
, although the syntax is slightly different (JMESPath) it eliminates the dependency. :)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ec2
Authors
Related Tags
#ec2
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#