AWS Cost Export
Export comprehensive AWS cost data for analysis and optimization.
Installation
pip install awscostexport
Quick Start
# Export default 12 months of cost data
awscostexport
# Export last 3 months
awscostexport --months 3
# Use specific AWS profile
awscostexport --profile prod-account
# Get help
awscostexport --help
# Use temporary credentials
awscostexport --access-key-id AKIA... --secret-access-key xxx --session-token xxx
# Filter by accounts
awscostexport --include-accounts 123456789012,234567890123
awscostexport --exclude-accounts 999999999999
# Use config file
awscostexport --config config.yaml
That's it! Your data will be exported as a zip file.
What You Get
The script exports comprehensive AWS cost data:
- Service breakdown - Top 10 services (marketplace excluded)
- EC2 analysis - Purchase options, instance types, Savings Plans vs RIs
- Database details - RDS engines, ElastiCache, DynamoDB configurations
- Reservation analysis - Complete RI/SP coverage for all eligible services
- Storage breakdown - EBS volume types (GP2, GP3, IO1)
- Network costs - Data transfer, NAT gateways
- Marketplace tracking - Separated from main costs
- Optimization metrics - Coverage %, utilization, on-demand opportunities
Output: Single zip file with 10+ CSV files ready for analysis.
Prerequisites
- Python 3.7 or later
- AWS credentials with Cost Explorer read access
AWS Credentials
The tool uses the standard AWS credential chain:
-
Environment variables
export AWS_ACCESS_KEY_ID="your-access-key" export AWS_SECRET_ACCESS_KEY="your-secret-key" export AWS_SESSION_TOKEN="optional-session-token"
-
AWS credentials file (~/.aws/credentials)
[default] aws_access_key_id = your-access-key aws_secret_access_key = your-secret-key [production] aws_access_key_id = prod-access-key aws_secret_access_key = prod-secret-key
-
AWS SSO
aws sso login --profile production awscostexport --profile production
-
IAM Instance Profile (when running on EC2)
Required IAM Permissions
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ce:Get*",
"ce:Describe*",
"cur:Describe*"
],
"Resource": "*"
}
]
}
Configuration File
Create a config.yaml file to store credentials and filters:
# AWS Credentials (optional)
credentials:
access_key_id: AKIAXXXXXXXXXXXXXXXX
secret_access_key: YYYYYYYYYYYYYYYYYYYY
session_token: ZZZZZZZZZZZZZZZZZZZZ # optional
# Account Filters (optional)
filters:
include_accounts:
- "123456789012"
- "234567890123"
exclude_accounts:
- "345678901234"
## Output
The script creates a **zip file** containing all your cost data:
| File | Description |
|------|-------------|
| 01_service_breakdown.csv | Top 10 services by cost (excludes marketplace) |
| 02_ec2_purchase_options.csv | EC2 on-demand vs reserved vs Savings Plans |
| 02a_ec2_instance_types.csv | EC2 instance types (if EC2 in top 10) |
| 03_rds_breakdown.csv | Database configurations |
| 03a_rds_engines.csv | Database engines |
| 04_savings_status.csv | Overall Savings Plans & RI coverage metrics |
| 05_container_services.csv | ECS/EKS/Fargate data (if in top 10) |
| 06_data_transfer_nat.csv | Network costs |
| 07_ebs_volumes.csv | Storage volume types |
| 08_marketplace_spend.csv | AWS Marketplace costs (separated) |
| 09_reservation_analysis.csv | **Comprehensive RI/SP analysis for all services** |
| AWS_COST_EXPORT_SUMMARY.md | Summary report |
## Troubleshooting
**"Cannot access AWS Cost Explorer"**
- Check your IAM permissions include `ce:*` access
- Verify credentials: `aws sts get-caller-identity`
- Cost Explorer needs 24 hours after first activation
**"No data returned"**
- Verify you have AWS costs in the time period
- Default exports last 6 months of data
## Support
Email: david.schwartz@devfactory.com
## License
MIT License - See LICENSE file for details.
Metadata
Release files for awscostexport 1.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| awscostexport-1.3.2.tar.gz | 15.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| awscostexport-1.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.4 kB
Release files / awscostexport-1.3.2.tar.gz
| Download URL | awscostexport-1.3.2.tar.gz |
|---|---|
| Size | 15.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b52d4a4b3efc89bb8bcf4d157d7a77e1a62b5e902b195e1ecd2f828a351e10be
|
|
BLAKE2b-256 checksum How to use checksums |
4b27d78d164cb1455fc8969fade2e3630518e7b99c9a75affe1b22362ed7d943
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.15
|
Release files / awscostexport-1.3.2-py3-none-any.whl
| Download URL | awscostexport-1.3.2-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
caf12437677d2d1d0e83c7960bf5f9832085fe54336187476564da538d324400
|
|
BLAKE2b-256 checksum How to use checksums |
88331a7edba93e209b78d2ab332bad1def68111bb71c8ffcb78e24720dcb2009
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.15
|