AWS Cost Report
CleanGenerate comprehensive daily AWS cost analysis reports with styled HTML templates.
SKILL.md
---
name: "AWS Cost Report"
description: Generate comprehensive daily AWS cost analysis reports with styled HTML templates. Use when asked to monitor AWS spending, analyze cost spikes, or setup recurring email reports for AWS accounts.
metadata:
openclaw:
requires:
env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"]
---
# AWS Cost Report
This skill generates a detailed, styled HTML report of AWS spending over the last 30 days using the Cost Explorer API.
## Authentication
The skill requires AWS credentials with access to the Cost Explorer API (`ce:*`) and basic identity info (`sts:GetCallerIdentity`).
1. **Environmental configuration**:
Set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` via:
`manage_skills(action="config", skill_name="aws-cost-report", env={"AWS_ACCESS_KEY_ID": "...", "AWS_SECRET_ACCESS_KEY": "..."})`
2. **Required Permissions**:
The IAM user must have the following policy:
- `ce:GetCostAndUsage` (Essential)
- `ce:GetDimensionValues`
- `sts:GetCallerIdentity`
- `ce:GetCostForecast` (Optional - fallback to manual projection if denied)
## Standard Workflow
### 1. Data Retrieval
Use `boto3` to pull data for the last 30 days:
- **Daily Spend**: Granularity `DAILY`, Metrics `UnblendedCost`.
- **Top Services**: Granularity `MONTHLY`, Group by `SERVICE`.
- **Regional Split**: Granularity `MONTHLY`, Group by `REGION`.
### 2. Report Generation
Apply data to the bundled HTML template in `assets/report_template.html`.
- **Anomaly Detection**: Flag any day exceeding 2x the rolling average.
- **MoM Comparison**: Compare current month-to-date with the previous period.
### 3. Delivery
Send the finished HTML via `send_gmail_message` with `body_format="html"`.
## Recurring Task Setup
To setup a daily report, create a recurring task with the following instruction pattern:
"Execute the aws-cost-report workflow daily at 11am PST and email the HTML result to [email]."
## Resources
- **Template**: [assets/report_template.html](assets/report_template.html) - Base structure for the HTML report.