/s3_analyzer

Shell Tool for analyzing AWS S3 buckets - Created as a response for Coveo Devops Challenge

Primary LanguagePythonMIT LicenseMIT

S3 Analyzer

This package is an analyzer for Amazon S3 consumption developed in Python3

Installation

The package is currently not available on PyPI. So, you first have to clone the repository, then cd into it and use:

pip install .

Please note that the package only works with Python3 and later version

Usage

The analyzer has two modes:

Global mode:

This mode allows you to see information about all your S3 buckets. You can access the global mode like this:

s3_analyzer global

The global analyzer supports the following options:

Short Name Long Name Description Possible Values Default Value
-gb --group-by Options to group buckets by. Leave empty to show everything in one list location None
-f --filter Filters the results. You can as many filters as you need. Each filter needs to look like:
-f property comparator value
For example:
-f name regex buckets*
The property can be one of:
* name
* creation_date
* number_of_files
* total_size
* last_modified
* location
The comparator can be one of:
* eq (equals)
* regex (matches regex)
* gt (greater than)
* lt (less than)
-su --size-unit The unit to use for sizes B, KB, MB, GB, TB B

Bucket mode:

This mode allows you to see information about a specific S3 bucket. You can access the bucket mode like this:

s3_analyzer bucket bucket_name

Where bucket_name is the name of your bucket

The bucket analyzer supports the following options:

Short Name Long Name Description Possible Values Default Value
-gb --group-by Options to group files by. Leave empty to show everything in one list storage_class None
-f --filter Filters the results. You can as many filters as you need. Each filter needs to look like:
-f property comparator value
For example:
-f key regex some_file*
The property can be one of:
* key
* size
* last_modified
* storage_class
The comparator can be one of:
* eq (equals)
* regex (matches regex)
* gt (greater than)
* lt (less than)
-su --size-unit The unit to use for sizes B, KB, MB, GB, TB B
-p --prefix only gets the objects that start with this prefix. This is different from filters in that filters fetch all the data but then filter it, while prefix only fetches the data that starts with that prefix None