by mathieuruellan · 12y ago · 0 comments
EDIT: here is one I used. Given VOLUME_ID, gets the most recent snapshot-id.
SNAPSHOT_ID=$(\
aws ec2 describe-snapshots --owner-ids xxxxxxxxxxxx --output json |
jq -r "
.Snapshots | sort_by(.StartTime) | reverse[] |
select(.VolumeId==\"$VOLUME_ID\" and .State==\"completed\") |
.SnapshotId
")
EDIT2: now that I'm looking at it, I think that I expected it to work with multiple snapshots but I'm not sure that I tested it. % aws ec2 describe-instances --instance-ids '["i-3026a249","i-28739551"]' \
| jq '[.Reservations[].Instances[].InstanceId]'
[
"i-28739551",
"i-3026a249"
]