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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file S3-Inspect-1.4.tar.gz.

File metadata

  • Download URL: S3-Inspect-1.4.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.7.3 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.7.2

File hashes

Hashes for S3-Inspect-1.4.tar.gz
Algorithm Hash digest
SHA256 0ddff5700de80c0db64b09f81f522f77ae2062cf61a344bbe38528a01861f552
MD5 6950e0b7fe6004acacb57fc869a2ae21
BLAKE2b-256 b12be6b42f23921e9873bc873b852f07f58af954153bbe661cab8cf4ae44d58d

See more details on using hashes here.

File details

Details for the file S3_Inspect-1.4-py3-none-any.whl.

File metadata

  • Download URL: S3_Inspect-1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.7.3 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.7.2

File hashes

Hashes for S3_Inspect-1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f7068edbe33ff3368b94bdee6ca66c568be2be8f4b78884fb606a4b8fc320ad4
MD5 acf32687c3518d5fc333b271935480c8
BLAKE2b-256 52fa9c836f2023fc88b7a7948b063f7bc6c0ead8ac1f31cb1a92eeb193d4e604

See more details on using hashes here.

Supported by

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