Skip to main content
![Bezos is a Hustler](http://i.imgur.com/Lw15zkJ.jpg)

django-aws-billing
==================

Django AWS Usage/Billing Package. **Work in Progress**.

* Version: 0.2.6
* Status: Working!

Maps items from CSVs in the AWS programmatic billing access reports to a **BillingRecord** model in Django, allowing billing
queries to be processed via the Django ORM. Also provides some convenience methods to calculate costs for specific
resources.

## Set up

1. First you need to set up [Programmatic Billing
Access](http://docs.aws.amazon.com/awsaccountbilling/latest/about/programaccess.html) and "detailed billing reporting
with resources and tags" from your [billing preferences
page](https://portal.aws.amazon.com/gp/aws/developer/account?ie=UTF8&action=billing-preferences). This also means making
a bucket to store the output in (those bastards, charging us to host our own billing data!), and setting up an
appropriate policy for that bucket.

1. Wait an hour for your first usage report to be generated. 😴

1. Install django-aws-billing:

```bash
pip install django-aws-billing
```

1. Set your AWS credentials in your Django settings:

```python
AWS_ACCESS_KEY = 'AKDERPDERPDERPDERPDERP'
AWS_SECRET_ACCESS_KEY = 'iL+HERPHERPHERPHERPHERPHERPSQUIRT'
AWS_BILLING_BUCKET = 'your-aws-billing-info-bucket-name'
AWS_ACCOUNT_ID = '1234-5679-0000' # Find this number from your AWS Manage Account page: https://portal.aws.amazon.com/gp/aws/manageYourAccount
```

1. Add 'aws\_billing' to your INSTALLED\_APPS:

```bash
INSTALLED_APPS = (
...
'aws_billing',
...
)
```

1. Run syncdb:

```bash
python manage.py syncdb
```

1. Run the billing command:

```bash
python manage.py process_aws_billing
```

1. You can then see the costs with:

```bash
python manage.py aws_costs
```

## Programmatic Usage

1. Import it and call it!

```python
from aws_billing import aws_billing
aws_billing.get_cost_for_resource('your-resource-name') # 12.002415
aws_billing.get_total_cost() # 42.001234
aws_billing.get_all_costs_by_resource() # {'your-resource-name': 12.002415, 'your-other-resource-name': 29.998819}
```

Hooray!

## TODO:

* Hopefully, this package will also include utilities to create nice little javascript charts.
* Something something timezones. And date ranges on the utilities.
* Tests
* Your idea here? The future is unwritten..

Issues welcomed, patches thanked, stars appreciated.

Release files for django-aws-billing 0.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-aws-billing 0.2.6
File Size Uploaded
django-aws-billing-0.2.6.tar.gz 6.2 kB Details

Release files / django-aws-billing-0.2.6.tar.gz

Download URL django-aws-billing-0.2.6.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
657b10d82cad42831ca1886c22460c889eb9a25b6357c236e0801d98fe7ef832
BLAKE2b-256 checksum
How to use checksums
c49787a7258e617cce6441a4c45fb8468cbef5fdcf3b19a7bc7b33072d1112ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.6 This release

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page