JQ STUFF I ALWAYS FORGET
if you have a list of dicts like
[
{"name": "fred",
"id": 1234},
{"name": "barmey",
"id": 4567}
...
]
it's
jq '.[] | .name'
If your json looks like { "HostedZones": [ { "Id": "/hostedzone/Z16YDE3PIPMD6Q", "Name": "bpmsuites.com.", "CallerReference": "5BA36045-A158-CF27-9ECC-A0C0262DCE16", "Config": { "Comment": "", "PrivateZone": false }, "ResourceRecordSetCount": 5 }, { "Id": "/hostedzone/Z05745354RXF132CEYNH", "Name": "campus-pass.com.", "CallerReference": "RISWorkflow-RD:a8da8e10-7268-40bd-baf3-e0943174c4bd", "Config": { "Comment": "HostedZone created by Route53 Registrar", "PrivateZone": false }, "ResourceRecordSetCount": 2 },
and you want the name and id elements, do aws --profile prod --region us-east-1 route53 list-hosted-zones | jq '.HostedZones[] | "(.Name) (.Id)"' | sed -e 's/"//g'
use -r to remove the need to sed out the "
use thee select() function to do something like this:
jq -r '.SecurityGroupForVpcs[] | select(.GroupName=="ATFAccessOnly") | .GroupId'
meaning at the root is a key called SecurityGroupForVpcs whose value is a list,
then foreach element of the list, for key == .GroupName and value == "ATFAccessOnly"
,
send the element and select the .GroupId key
to print 2 things separated by tabs: aws --profile prod --region us-east-1 lambda list-functions | jq -r '.Functions[] | [.FunctionName, .LastModified] | @tsv'