lljygq
Last Updated: September 07, 2016
·
788
· lorin
Me pixel

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"
}
Say Thanks
Respond

1 Response
Add your response

28143
37ccf75d1b630ee371b7aeb06c8f7d4c

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 ·