Skip to main content

A package to inspect contents of S3 buckets and generate report

Project description

aws-devops-challenge

Getting Started

  1. Get the AWS API Key and Secret
  2. Place create a folder ~/.aws/ mkdir -p ~/.aws/
  3. Create credentials file inside ~/.aws/ folder vi ~/.aws/credentials. The contents of the file should look like this:
[default]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
  1. (Optional)You can choose to create ~/.aws/config file to select your default region:
touch ~/.aws/config
[default]
region = YOUR_PREFERRED_REGION
  1. (Optional) Note: It is recommended but not required to create a python environment using: python3 -m venv YOUR_PYTHON_ENV_NAME source YOUR_PYTHON_ENV_NAME/bin/activate

  2. Install s3-inspect using the following:

pip install s3-inspect
  1. Running the python package

python -m s3inspect -h

usage: __main__.py [-h] [-u {b,kb,mb,gb}] [-p PREFIX] [-gs] [-gr] [-gc]
                   [--timeperiod TIMEPERIOD] [--granularity GRANULARITY]
                   [--metrics METRICS] [-l]
                   regex

Inspect S3 Bucket

positional arguments:
  regex                 Regex Support for Buckets list)

optional arguments:
  -h, --help            show this help message and exit
  -u {b,kb,mb,gb}, --unit {b,kb,mb,gb}
                        Return files sizes in these units: b (bytes), kb
                        (kilobytes), mb (megabytes), gb (gigabytes)
  -p PREFIX, --prefix PREFIX
                        Add prefix for the keys. Example: images/
  -gs, --groubystoragetype
                        When this is set information is grouped by Storage
                        Type
  -gr, --groubyregion   When this is set information is grouped by Region Type
  -gc, --getcost        When this is set cost report is returned Type
  --timeperiod TIMEPERIOD
                        Example: '{"Start":"2019-01-01","End":"2019-05-20"}'
  --granularity GRANULARITY
                        Example: MONTHLY
  --metrics METRICS     Example: 'BlendedCost UNBLENDED_COST AMORTIZED_COST'
  -l, --list            Displays a list of available S3 Buckets in account

Examples

  • Following is to use only regex for bucket name
$ python s3inspect test*

------------------------------------------------------------------
S3 Bucket Inspection Report:
------------------------------------------------------------------
Bucket Name: tests32424312341234
------------------------------------------------------------------
Bucket Creation Date: 2019-05-21 08:04:15+00:00
Recent File Modification Date (Bucket): 2019-05-21 08:08:38+00:00
Total Files: 3
Total Files Size = 0.003 MB
  • The following is an example to get Cost Summary in Json format time python s3inspect -gc --granularity MONTHLY --metrics 'BlendedCost' --timeperiod '{"Start":"2019-01-01","End":"2019-05-20"}' test*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

S3-Inspect-1.4.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

S3_Inspect-1.4-py3-none-any.whl (8.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page