Photo by Denny Müller on Unsplash
Automates creation of detailed inventories from AWS resources.
Expand
aws-auto-inventory --help
usage: aws-auto-inventory [-h] --name NAME
Automates creation of detailed inventories from AWS resources.
optional arguments:
-h, --help show this help message and exit
--name NAME, -n NAME inventory name
Projects usually have several resources and fetching all the information about these resources manually is a very time-consuming task. This issue is intensified when the same project have multiple account and/or environments, e.g.: NonProd, QA and/or Prod.
Provide a simple way to fetch the required information and generate a spreadsheet. The information can be filtered, e.g. filter results by tag:x, vpc, subnets, etc. Additionally, inventories can be generated related to many services, which are collected and organized per sheet in the spreadsheet.
# Linux/MacOS:
# clone the project and enter cloned directory
make init build
./dist/aws-auto-inventory --name <your-inventory-name>
Expand
You will need to create a config.yaml
file in order to tell the tool how to generate your inventory, here are the default search paths for each platform:
- OS X:
~/.config/aws-auto-inventory/config.yaml
or~/Library/Application Support/aws-auto-inventory/config.yaml
- Other Unix:
$XDG_CONFIG_HOME/aws-auto-inventory/config.yaml
or~/.config/aws-auto-inventory/config.yaml
- Windows:
%APPDATA%\aws-auto-inventory\config.yaml
where theAPPDATA
environment variable falls back to%HOME%\AppData\Roaming\config.yaml
if undefined
You can use the config-sample as an example. A snippet can be found below:
inventories:
- name: your-inventory-name
aws:
profile: your-aws-profile
region:
- us-east-1
excel:
transpose: true
sheets:
- name: EC2 # sheet name on Excel
service: ec2 # the boto3 client of an AWS service
function: describe_instances # the client method of the service defined above
result_key: Reservations # [optional]: The first key of the response dict
- name: EBS
service: ec2
function: describe_volumes
result_key: Volumes
If you are interested in building an inventory for multiple AWS Accounts (within your AWS organization) with the same sheets, you can use the config-sample-for-organization for simplicity. Code snippet:
Sheets: &sheets
- name: CloudFrontDistros
service: cloudfront
function: list_distributions
result_key: DistributionList
- name: S3Buckets
service: s3
function: list_buckets
result_key: Buckets
inventories:
- name: your-org-master
aws:
profile: your-org
region:
- us-east-1
excel:
transpose: true
sheets: *sheets
- name: your-org-account1
aws:
profile: your-org-account1
region:
- us-east-1
excel:
transpose: true
sheets: *sheets
- name: your-org-account2
aws:
profile: your-org-account2
region:
- us-east-1
excel:
transpose: true
sheets: *sheets
Then you need to run the auto-inventory script multiple times for your accounts as follows:
./dist/aws-auto-inventory --name your-org-master
./dist/aws-auto-inventory --name your-org-account1
./dist/aws-auto-inventory --name your-org-account1
Now, download the binary according to your operating system and platform and execute it, informing which inventory you want to generate.
The tool will create a folder aws-auto-inventory-report
, in the current path, with the inventory report inside.
Expand
AWS-Auto-Inventory uses boto3. You can use any service that contains any list or describe method to fetch information about your resources.
You can use boto3 parameters to narrow down your search results.
sheets:
- name: VPC
service: ec2
function: describe_vpcs
result_key: Vpcs
parameters:
Filters:
- Name: tag:Name
Values:
- my-vpc
sheets:
- name: Subnets
service: ec2
function: describe_subnets
result_key: Subnets
parameters:
Filters:
- Name: vpc-id
Values:
- vpc-xxx
sheets:
- name: RDS
service: rds
function: describe_db_instances
result_key: DBInstances
parameters:
DBInstanceIdentifier: the-name-of-my-rds-instance
sheets:
- name: EC2
service: ec2
function: describe_instances
result_key: Reservations
parameters:
Filters:
- Name: tag:ApplicationName
Values:
- my-application
sheets:
- name: IAM.Role
service: iam
function: get_role
result_key: Role
parameters:
RoleName: my-role
See CONTRIBUTING for more information.
This project is licensed under the Apache License 2.0.
For more information please read LICENSE.
Amazon, Inc. or its affiliates. All Rights Reserved.