Photo by Denny Müller on Unsplash
AWS Automated Inventory ( aws-auto-inventory )
Automates creation of detailed inventories from AWS resources.
Table of Contents
Screenshots
Usage
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
Problem
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.
Solution
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.
Development
# Linux/MacOS:
# clone the project and enter cloned directory
make init build
./dist/aws-auto-inventory --name <your-inventory-name>
Installing
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.
Testing
Expand
AWS-Auto-Inventory uses boto3. You can use any service that contains any list or describe method to fetch information about your resources.
Parameters
You can use boto3 parameters to narrow down your search results.
Filter by tag:Name
sheets:
- name: VPC
service: ec2
function: describe_vpcs
result_key: Vpcs
parameters:
Filters:
- Name: tag:Name
Values:
- my-vpc
Filter by vpc-id
sheets:
- name: Subnets
service: ec2
function: describe_subnets
result_key: Subnets
parameters:
Filters:
- Name: vpc-id
Values:
- vpc-xxx
Find a particular RDS instance
sheets:
- name: RDS
service: rds
function: describe_db_instances
result_key: DBInstances
parameters:
DBInstanceIdentifier: the-name-of-my-rds-instance
Find EC2 instances by a particular tag
sheets:
- name: EC2
service: ec2
function: describe_instances
result_key: Reservations
parameters:
Filters:
- Name: tag:ApplicationName
Values:
- my-application
Find a particular IAM Role
sheets:
- name: IAM.Role
service: iam
function: get_role
result_key: Role
parameters:
RoleName: my-role
Contributors
Expand
Name | Role | |
---|---|---|
Silva, Valter | [email protected] | AWS Professional Services - Cloud Architect |
Security
See CONTRIBUTING for more information.
References
License
This project is licensed under the Apache License 2.0.
For more information please read LICENSE.
Copyright
Amazon, Inc. or its affiliates. All Rights Reserved.