Is there a tool to convert AWS json data ( SGs, NACLs, etc) into a spreadsheet that is more human readable?

I’ve been working with json files in the table format and I’d love a way to convert these into a spreadsheet so a human could easily search and filter the data. Any ideas?

My company requires us to regularly audit all of the account data and it’s so tedious. Help!

Edit - To provide a bit more context, I don’t have access to the AWS accounts I have to do this for. I can only request the data be generated for me and I try to get the json files output with the table format which does help with excel.

Json - “the non-human readable data structure”

If all you want is to basically convert it to a csv that you could open in excel you could use the python pandas library to create a Dataframe from the json, then write it to a csv with Dataframe.to_csv().

Well, it’s a bit more than that. Ultimately I want to sort the data into a grouping that is more suited for filtering based on column names like vpcid, groupie, group name, description, etc. Taking values from the json but changing the structure of the arrangement is that makes sense.

I’ve been doing if with excel formulas, equals and if statements, stuff like that. It’s mostly the same thing every time I have to do it but I haven’t found a way to automate the data transform besides copying and pasting formulas in excel.

Could you leave it as json and automate the audit?

(Hint: yes, and you should)

Furthermore: what benefit do they see from a manual audit that you can’t get from cloud trail logs?

Well, I certainly understand that reasoning. This is more a check this out and let me know if anything is wrong situation. With this compliance program I work with, part of the process is having a independent party (me) review/check networking configs from the cloud environments. You can’t really do that without getting a dump of json logs.

So that leads me to creating spreadsheets of data from json output provided to me.

Steampipe is an open source tool that allows you to list and query your AWS resources using SQL. It supports CSV output, and can be connected to directly as a database source. It also has special queries to support expansion of things like security group rules.

For example, use the aws_vpc_security_group_rule table to get a list of security groups whose inbound access is open to the internet:

select
group_name,
group_id,
type
from
aws_vpc_security_group_rule
where
type = ‘ingress’
and cidr_ip = ‘0.0.0.0/0’;

Have you tried Power Query?

First there’s this:
https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-output-format.html

AWS CLI can output to text, which is a TSV file that can be imported to a spreadsheet. Though it’s still not going to be pretty for complex outputs.

eg.

aws ec2 describe-security-groups --output text > /tmp/securitygroups.tsv

If you want to go beyond spreadsheets, have a look at this:
https://steampipe.io/

I’ve written some scripts that did this before. Just used boto3 and some Excel library I found. It’s not too bad.

Steampipe, pandas and cli text output are all solid solutions for the question you initially asked. Unfortunately, without more context, it is hard to determine if it was the right question to be asking in the first place.

You use the “c” word but any true compliance regimen will have clear and specific criteria for violations that you would check each rule/list/group against. If you don’t have / do this already you should ask what you’re actually accomplishing in this exercise. The point of an audit is to verify reproducible results and detect anomalies. Anything less is simply opinion and, depending on your industry, arguably negligent. You must do away with the toil of reviewing a spreadsheet of security groups and nacls. This is an almost laughable waste of time and if your compliance people insist on manual review of a spreadsheet then find another gig, as this will land squarely on your shoulders when a breach does occur. Its hard to fault the writer of peer reviewed autonation code. It is very easy to point the finger at the person that visually inspected hundreds of lines of nearly identical values and missed a single digit or comma or mixed up allow with deny.

As far as actually implementing a proper system, that is well above reddit’s pay grade but I’ve done it before and you should start with some simple text comparison in python with the JSON as input. Seriously though what if you never had to open an excel spreadsheet again? Also, how often can you reasonably be expected to review this data? If that’s all you do all day everyday then it’s a massive waste of time. If you only get to it once a week or once a month or once a quarter, it’s still a massive waste of time and any nefarious actors will be long gone before you’ve even opened your log dump.

Once you’ve automated the review of your existing resources get to work on being reactive rather than retroactive. This will require triggering alerts on cloud trail events for security groups and ACLs to be reviewed by a lambda function which could alert or remediate automatically. Checkout this article for an example https://towardsdatascience.com/protect-your-infrastructure-with-real-time-notifications-of-aws-console-user-changes-3144fd18c680
Then your report to compliance becomes a list of things that you’ve already fixed rather than “things that look off”. This may seem like a mountain being made out of a molehill but frankly you asked for a beach umbrella during a hurricane.

Check out CloudMapper (by Duo Labs on GitHub I think). Or maybe cs-suite might have something similar.

I run both daily and archive results to S3 for the auditors. Consider ECS Fargate or I just schedule a job in our CI system.

You can pipe aws cli json output into jq and restructure the data however you want, including converting it to csv where appropriate. jq is a swiss army knife for json manipulation.

This at least solves the ‘get the data into the structure I want’. It doesn’t do much for the excel formula side of things. But you should be able to reference external CSV from within excel and make it reasonably easy. Just update the referenced file and refresh?

Check this out: https://github.com/chetanku/roster , developed this from an inventory perspective, for upper management visibility…there is a demo link in readme.md

Can you store the JSON files in S3 and then query them with Athena?

I’m surprised nobody suggested jq. With jq you can filter down to what you’re looking for and cut out the rest. It’s not going to fix everything, but it certainly will be more readable.

That is what a friend suggested but I want sure where to start. Any idea on the excel library you used?

https://xlsxwriter.readthedocs.io/

I’ve looked at it before, but I get intimidated reading through the manual. I need to look at it again.

Hmm, this might be something I can mess with. I never have done anything with Python but it looks promising!