Skip to main content

Aviv AWS CostExplorer python library

Project description

Aviv AWS CostExplorer

Aims to provide a quick and comprehensive interface to AWS costexplorer api. This is useful to extract cost and usage (aka CAU) data, save it and to make it available for reporting and analysis.

Requirements

  • python >= 3.8
  • boto3
  • Access to AWS ce:cost_and_usage

Usage

pip install aviv-aws-costexplorer

# Install additional libraries required to save/read data on AWS S3: pandas, awswrangler
pip install aviv-aws-costexplorer[datastore]

Sample code

from aviv_aws_costexplorer import costreporter

cr = costreporter.CostReporter()
costs = cr.get_cost_and_usage()
# Will print you last 3 months costs
print(costs)

from aviv_aws_costexplorer import datastore
ds = datastore.DataStore(database='test', bucket='my-s3-bucket')
ds.to_parquet(data=costs, path='monthly/last3', database='monthly')

# Show it nicely
import pandas as pd
df = pd.DataFrame(costs)
df.head()


# Store on S3 and make it available through Athena (uses awswrangler)

Development

pipenv install -d

Test, Build, Release

We typically follow the standard python packaging and distribution process to release this package.

# Run tests
pipenv run pytest -v tests/

# Build python package
python3 -m pip install --upgrade build
python3 -m build

# Release on testpypi
python3 -m pip install --upgrade twine
python3 -m twine upload --repository testpypi dist/*

Note: the Pypi release is also done during the CICD process.

Contribute

Yes please! Send us your PR's

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

aviv-aws-costexplorer-0.2.3.tar.gz (12.4 kB view hashes)

Uploaded Source

Built Distribution

aviv_aws_costexplorer-0.2.3-py3-none-any.whl (14.8 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