This script Fetches AWS resources across multiple accounts and regions:
- VPC
- EC2 Instances
- RDS Databases
- S3 Buckets
- Security Groups
- IAM Roles
- Subnets
- EBS Volumes
- Network ACLs
The results are stored in resources.db and summarized/displayed in the terminal
python3 -m venv venv
source venv/bin/activatepython -m venv venv
.\venv\Scripts\activateOnce the virtual environment is activated, install the required dependencies:
pip install -r requirements.txtMake sure your AWS CLI is configured with valid credentials:
aws configure --profile <profile-name>You will need to provide your AWS Access Key ID, Secret Access Key, default region, and output format.
respect the ~/.aws/credentials structure for example :
cat ~/.aws/credentials
[default]
aws_access_key_id = <your acess key>
aws_secret_access_key = <your secret access key>Create or update the configuration file config.json inside the config/ folder. The file should have the following structure for multiple accounts:
{
"accounts": [
{
"account_name": "ROOT_ACCOUNT(whatever)",
"profile_name": "default", # name in ~/.aws/credentials
"regions": ["us-west-2", "eu-central-1"] # or put [] for all regions fetch
}
# add other accounts/profiles
]
}- accounts: A list of AWS accounts to access.
- profile_name: The AWS profile inside the account or for cross-account access.
- regions: (Optional) A list of regions to query. If omitted, the script will prompt the user to input regions.
python3 aws_inventory.pypython aws_inventory.py- The
config.jsonfile must be located in aconfig/directory relative to the script. - If no regions are provided in the
config.jsonfile, the script will prompt the user for input. - The AWS CLI must be configured with access and secret keys for accessing AWS resources.
- The script only retrieves the following AWS resources:
- VPC
- EC2 Instances
- RDS Databases
- S3 Buckets
- Security Groups
- IAM Roles
- Subnets
- EBS Volumes
- Network ACLs
The script stores the fetched data in the resources.db SQLite database file located in the output_files/ folder. To access the data, you can use the following command:
sqlite3 output_files/resources.dbOnce inside the SQLite shell, you can view all the resources with:
SELECT * FROM resources;- output.txt: Contains a clean summary of the resources enumerated.
- log.txt: Contains the log of the last run, useful for debugging.