Jq Notes

From Federal Burro of Information
Revision as of 18:59, 13 November 2017 by David (talk | contribs)
Jump to navigationJump to search


Selecting name from tags:

aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.LaunchTime > "2015-01-28") | select(.State.Code != 48) | [(.Tags[]|select(.Key=="Name")|.Value),.LaunchTime, .State.Name] | join(", ")'


to CSV (join on the end ):

azure location list --json | jq '.[] | .name  | join(", ")'

AWS account report:

cat get_accounts_v4.json | jq '.accounts_and_users | .[] | select(.aws_account_id != null) | { account_name: .account_name, aws_account_id: .aws_account_id }| join(",")' > aws_accounts.report

Azure account report:

cat get_accounts_v4.json | jq '.accounts_and_users | .[] | select(.azure_account_id != null) | { account_name: .account_name, azure_account_id: .azure_account_id }| join(",")' > azure_accounts.report


Also See