This command line tool counts the number of resources in different categories across Amazon regions.

This is a simple Python app that will count resources across different regions and display them on the command line. It first shows the dictionary of the results for the monitored services on a per-region basis, then it shows totals across all regions in a friendlier format. It tries to use the most-efficient query mechanism for each resource in order to manage the impact of API activity. I wrote this to help me scope out assessments and know where resources are in a target account.

The development plan is to upgrade the output (probably to CSV file) and to continue to add services. If you have a specific service you want to see added just add a request in the comments.

The current list incluides:

Application and Network Load Balancers

Autoscale Groups

Classic Load Balancers

CloudTrail Trails

Cloudwatch Rules

Config Rules

Dynamo Tables

Elastic IP Addresses

Glacier Vaults

IAM Groups

Images

Instances

KMS Keys

Lambda Functions

Launch Configurations

NAT Gateways

Network ACLs

IAM Policies

RDS Instances

IAM Roles

S3 Buckets

SAML Providers

SNS Topics

Security Groups

Snapshots

Subnets

IAM Users

VPC Endpoints

VPC Peering Connection

VPCs

Volumes

Usage:To install just copy it where you want it and instally the requirements:

pip install -r ./requirements.txt

This was written in Python 3.6.To run:

python count_resources.py

By default, it will use whatever AWScredentials are alerady configued on the system. You can also specify an access key/secret at runtime and this is not stored. It only neeeds read permissions for the listed services- I use the ReadOnlyAccess managed policy, but you should also be able to use the SecurityAudit policy.

Usage: count_resources.py [OPTIONS]

Options: --access TEXT AWS Access Key. Otherwise will use the standard credentials path for the AWS CLI. --secret TEXT AWS Secret Key --profile TEXT If you have multiple credential profiles, use this option to specify one. --help Show this message and exit.