Skip to content

Instantly share code, notes, and snippets.

@amgill
amgill / ec2_sg_rules.py
Last active June 18, 2024 10:12
Generate AWS Security Groups Rules Report of all the Security Groups, as Seen via AWS Web Console. Uses python 3 with boto3 to generate CSV.
#!/usr/local/bin/python3
######################################################################################################################
# Purpose: Generate rules report of all the security groups #
# Input Params: None [Make sure to set AWS CLI session by populating env. vars. with keys.] #
# Usage: ./ec2_sg_rules.py > account-date.csv [python ./ec2_sg_rules.py > gill-dev-sg-2018-04-11.csv] #
# Author: Abdul Gill #
# Doc. Ref: http://boto3.readthedocs.io/en/latest/reference/services/ec2.html#EC2.Client.describe_security_groups#
######################################################################################################################
from __future__ import print_function