Skip to content

How to use it?

Janiko edited this page Mar 5, 2021 · 3 revisions

For now, all inventories are executed, so this script may be a little long. By default, all known services are inventoried. You just have to type :

$ python ./inventory

Arguments

There are a couple of useful arguments to know.

Services

First, you may call this script only for desired services. For instance :

$ python ./inventory --services efs ecs acm

It will reduce the time of processing, of course.

Informations

A log file is created and updated during execution. You may choose the level of logging by using one of these keywords, added anywhere in the command line :

  • debug
  • info
  • warning
  • error

The default level is warning (when you don't use any log level in command line).

$ python ./inventory --log debug will log all possibles messages.

$ python ./inventory --services ec2 acm --log error will only log errors trapped by the script.

AWS IAM rights

Don't forget to execute the script with appropriate IAM rights, that means your user has all the rights described in the policy files. You can attach directly the policies to the user, or to a group bound to the user, or to a role.

Profiles

If you have multiple profiles in your AWS CLI configuration file (in [HOME]\.aws\credentials), you can choose which one to use. By default, it's... default. The script will stop in case of non-existent profile.

$ python ./py inventory.py --profile toto --services ec2 s3 efs

If you want to execute this script within multiple AWS accounts, you should use AWS roles.

With lambda?

To come. Or not.

Clone this wiki locally