lljygq
Last Updated: September 07, 2016
·
1.03K
· lorin

Get AMI id and snapshot ID by tag

ec2

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"
}

1 Response
Add your response

28143

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 ·
Awesome Job

Frontend Web Developer for Games
·
Leamington Spa (United Kingdom)
·
Full Time