https://github.com/guessi/aws-cost-explorer-report
  
  
    AWS Cost Explorer Pretty Report written in Python 
    https://github.com/guessi/aws-cost-explorer-report
  
aws cost-explorer python3
        Last synced: 2 months ago 
        JSON representation
    
AWS Cost Explorer Pretty Report written in Python
- Host: GitHub
- URL: https://github.com/guessi/aws-cost-explorer-report
- Owner: guessi
- License: gpl-3.0
- Created: 2020-06-28T08:13:11.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-04-26T17:51:10.000Z (6 months ago)
- Last Synced: 2025-08-17T04:33:24.091Z (3 months ago)
- Topics: aws, cost-explorer, python3
- Language: Python
- Homepage:
- Size: 38.1 KB
- Stars: 9
- Watchers: 2
- Forks: 5
- Open Issues: 0
- 
            Metadata Files:
            - Readme: README.md
- License: LICENSE
 
Awesome Lists containing this project
README
          # AWS Cost Explorer Pretty Report written in Python
## Prerequisites
- Python 3.10 (or later)
## Setup Requirements
```bash
$ pipenv install
```
or
```bash
$ pip3 install -r requirements.txt
```
## Usage
```bash
$ ./aws-cost-explorer-report.py --help
Usage: aws-cost-explorer-report.py [OPTIONS]
Options:
  -P, --profile TEXT  profile name
  -S, --start TEXT    start date (default: 1st date of current month)
  -E, --end TEXT      end date (default: last date of current month)
  --help              Show this message and exit.
```
## Examples
check cost explorer report of date range [2024-01-01,2024-01-31]
```bash
$ ./aws-cost-explorer-report.py -P my-profile -S 2024-01-01 -E 2024-01-31
+-----------------+---------------+----------------------------------------+------------+
| TimePeriodStart | LinkedAccount | Service                                |     Amount |
+-----------------+---------------+----------------------------------------+------------+
| 2024-01-01      | 123456789012  | AWS Key Management Service             |    1.39938 |
| 2024-01-01      | 123456789012  | AWS Lambda                             |    3.00102 |
| 2024-01-01      | 123456789012  | EC2 - Other                            |   11.48211 |
| 2024-01-01      | 123456789012  | Amazon Elastic Compute Cloud - Compute |  102.41709 |
| 2024-01-01      | 123456789012  | Amazon Elastic Load Balancing          |   17.73890 |
| 2024-01-01      | 123456789012  | Amazon Route 53                        |    1.32980 |
| 2024-01-01      | 123456789012  | Amazon Simple Notification Service     |    2.32891 |
| 2024-01-01      | 123456789012  | Amazon Simple Storage Service          |    3.34789 |
| 2024-01-01      | 123456789012  | AmazonCloudWatch                       |   10.32789 |
| 2024-01-01      | 123456789012  | AWS Key Management Service             |    3.97408 |
| 2024-01-01      | 123456789012  | AWS Lambda                             |   23.44120 |
| 2024-01-01      | 123456789012  | EC2 - Other                            |   12.30661 |
| 2024-01-01      | 123456789012  | Amazon Elastic Compute Cloud - Compute |  127.45739 |
| 2024-01-01      | 123456789012  | Amazon Elastic Load Balancing          |   18.15638 |
| 2024-01-01      | 123456789012  | Amazon Route 53                        |    1.32456 |
| 2024-01-01      | 123456789012  | Amazon Simple Notification Service     |    2.00011 |
| 2024-01-01      | 123456789012  | Amazon Simple Storage Service          |    3.63218 |
| 2024-01-01      | 123456789012  | AmazonCloudWatch                       |   10.06860 |
+-----------------+---------------+----------------------------------------+------------+
```
## Equivalent command with `awscli`
check cost explorer report of date range [2024-01-01,2024-01-31]
```bash
$ aws --profile my-profile \
    ce get-cost-and-usage \
      --time-period "Start=2024-01-01,End=2024-01-31" \
      --granularity "MONTHLY" \
      --metrics "UnblendedCost" \
      --group-by "Type=DIMENSION,Key=LINKED_ACCOUNT" \
      --group-by "Type=DIMENSION,Key=SERVICE" \
      --output json
```
# License
[MIT LICENSE](LICENSE)