News for hackers. Stuff that matters.
Re:Jq: A lightweight and flexible command-line JSON processor by gatehouse on Sunday June 15, 2014 @07:52PM (#7896768)
I've been using it for the exact same thing. One difficulty that I had was that you need to use the raw option, "jq -r" for string output without quotes, but I was looking at the query language documentation and not finding it.

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.

There are no comments on this comment yet.