nccgroup / aws-inventory

Discover resources created in an AWS account.
Apache License 2.0
704 stars 131 forks source link

Filtering with jq #23

Closed SohamChakraborty closed 5 years ago

SohamChakraborty commented 5 years ago

Hi,

So I am trying to filter the data using jq. What I am after is the instance ids of the ec2 instances. I got to the part where I can see all the outputs of the text key, but then I am not able to drill down further. This is not really a tool specific help, but I am quite sure that some jq filtering examples in the readme.md file may prove beneficial. If I run jq '.responses[].children[].children[].children[].text' on the aws-inventory/gui/ file, I get this:

"DescribeCustomerGateways (1)"
"DescribeIdFormat (1)"
"DescribeNetworkAcls (1)"
"DescribePrefixLists (1)"
"DescribeSpotInstanceRequests"
"DescribeVpcClassicLink (1)"
<SNIPPED>

Now, I want to drill further down and and see things inside of "DescribeInstances (1)". How is that possible?

P.S. I ran the script with --service ec2 only.

bitsandsalsa commented 5 years ago

If you filter on one region and one service on the commandline with --services and --regions, then the following should get what you want: jq '.responses[].children[].children[].children[] | select(.text | startswith("DescribeInstances"))' file.json