AI-powered AWS cost analysis that identified $15,400/month in optimization opportunities across EC2, RDS, and S3 β fully automated, Slack-delivered, production-ready.
Cloud teams waste thousands on idle resources every month β not because they don't care, but because manual cost review doesn't scale. This tool automates the entire FinOps loop: fetch β analyze β recommend β alert β track.
Built by a DevOps engineer who's operated 24/7 broadcast infrastructure where every dollar of cloud spend is visible and accountable.
| Metric | Result |
|---|---|
| π° Monthly savings identified | $15,400/month |
| βοΈ Services analyzed | EC2, RDS, S3, Lambda, NAT Gateway, KMS |
| β‘ Time to first recommendation | < 2 minutes |
| π¬ Delivery | Automated Slack weekly reports |
| ποΈ Deployment | Docker + Terraform on AWS |
βββββββββββββββββββ ββββββββββββββββββββββββ ββββββββββββββββββββ
β AWS Account ββββββΆβ Python Engine ββββββΆβ LLM Provider β
β Cost Explorer β β - Cost fetching β β Claude / OpenAI β
β (CUR / API) β β - Anomaly detection β ββββββββββββββββββββ
βββββββββββββββββββ β - Forecasting β β
β - ROI ranking β βΌ
ββββββββββββ¬ββββββββββββ ββββββββββββββββββββ
β β Recommendations β
ββββββββββ΄βββββββββ β + Action Items β
β β ββββββββββββββββββββ
βββββββΌβββββββ βββββββββΌβββββββ
β Flask Web β β Slack Webhookβ
β Dashboard β β (Weekly) β
β Chart.js β ββββββββββββββββ
ββββββββββββββ
For regulated environments (banking / fintech):
CUR β S3 β Athena (auditable SQL) β EventBridge β Lambda β Dashboard
Fully governed, deterministic, KMS-encrypted, IAM-scoped.
| Feature | Description |
|---|---|
| π Cost Analysis | 7/30/90-day spend breakdown by service, account, tag |
| π€ AI Recommendations | Claude or OpenAI ranks opportunities by ROI |
| π¨ Anomaly Detection | Z-score + IQR detects spend spikes before they escalate |
| π Forecasting | 30-day cost projections with confidence intervals |
| πΎ Savings Tracker | Tracks implemented optimizations and ROI over time |
| π§ Auto-Remediation | Generates Terraform stubs for approved changes |
| π Web Dashboard | Flask + Chart.js with SSE real-time updates |
| π PDF Export | Print-ready reports from the dashboard |
| π¬ Slack Integration | Weekly automated delivery with action items |
| π³ Docker + Compose | One-command local or cloud deployment |
| βοΈ Terraform | Production AWS deployment via IaC |
| π Security | Token auth, DRY_RUN mode, IAM least-privilege |
- Python 3.11 or 3.12 (not 3.14)
- AWS account with Cost Explorer enabled
- OpenAI or Claude API key
- Slack webhook (optional)
git clone https://github.com/nickcube2/AI-Cost-Optimization-Dashboard.git
cd AI-Cost-Optimization-Dashboard
pip install -r requirements.txtcp .env.example .env# .env
AWS_REGION=us-east-1
LLM_PROVIDER=anthropic # anthropic | openai | mock
CLAUDE_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
SLACK_WEBHOOK_URL=https://hooks.slack.com/...
MONTHLY_BUDGET=5000
DAYS_TO_ANALYZE=30
DRY_RUN=falseCLI (quickest)
python cost_optimizer.pyWeb Dashboard (local)
python app.py
# Open http://localhost:5000Demo mode (no AWS creds needed)
python advanced_optimizer.py --demoDocker
docker compose up --build
# Open http://localhost:5000# Dashboard
docker run --rm -p 5000:5000 --env-file .env \
-e DASHBOARD_HOST=0.0.0.0 \
ai-cost-optimization-dashboard
# CLI workflow
docker run --rm --env-file .env \
ai-cost-optimization-dashboard python advanced_optimizer.py --democd terraform
cp terraform.tfvars.example terraform.tfvars
terraform init && terraform plan && terraform apply# Makefile shortcuts
make tf-plan
make tf-apply
make tf-destroy# With AI-powered 30-day forecast
python advanced_optimizer.py --report --ai-forecast
# Auto-remediation plan + Terraform stubs (dry-run safe)
python advanced_optimizer.py --auto-remediate --generate-terraform
# Full report output
python advanced_optimizer.py --reportββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π AI COST OPTIMIZATION DASHBOARD
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Fetching AWS cost data for last 30 days...
π
Date range: 2026-01-17 to 2026-02-16
π Trend: up 8.4% vs previous 30 days
β
Total: $12,858.00 | Services: 12
π° Cost Distribution:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
EC2 ββββββββββββββββββββ $ 4,892.00
RDS ββββββββββββββ $ 3,241.00
S3 ββββββββ $ 2,180.00
Lambda ββββ $ 890.00
NAT Gateway ββ $ 520.00
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π€ AI RECOMMENDATIONS
## π SPENDING OVERVIEW
Total: $12,858 | Trend: +8.4% | Budget: On Track
## π° TOP OPPORTUNITIES
1. EC2 Right-sizing (prod cluster) β Save $4,200/mo [Quick Win]
2. RDS Reserved Instance conversion β Save $1,800/mo [Medium]
3. S3 Intelligent-Tiering (archive) β Save $950/mo [Quick Win]
4. NAT Gateway consolidation β Save $380/mo [Medium]
ROI Total: $7,330/month β $87,960/year
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": [
"ce:GetCostAndUsage",
"ce:GetCostForecast",
"ce:GetDimensionValues",
"ce:GetReservationUtilization"
],
"Resource": "*"
}]
}DASHBOARD_API_TOKENβ token-based auth for all/api/*endpointsDRY_RUN=trueβ full execution without any API chargesDASHBOARD_CACHE_TTLβ prevents repeated AWS API calls- IAM scoped to read-only Cost Explorer permissions
- VPC endpoint support for regulated environments
ai-cost-optimization-dashboard/
βββ app.py # Flask web dashboard (SSE + Chart.js)
βββ cost_optimizer.py # Core optimizer (CLI entry point)
βββ advanced_optimizer.py # Multi-feature demo runner
βββ anomaly_detector.py # Z-score + IQR anomaly detection
βββ cost_forecaster.py # 30-day cost forecasting
βββ auto_remediator.py # Terraform auto-remediation stubs
βββ savings_tracker.py # ROI tracking over time
βββ llm_client.py # Cloud-agnostic LLM client (Claude/OpenAI)
βββ dashboard_data.py # Dashboard JSON payload builder
βββ Dockerfile # Container definition
βββ docker-compose.yml # Local orchestration
βββ Makefile # Convenience commands
βββ terraform/ # AWS infrastructure as code
βββ static/ # Frontend assets
βββ templates/ # Flask HTML templates
βββ screenshots/ # Dashboard preview images
βββ reports/ # Generated cost reports
- Core cost analysis + AI recommendations (Week 1)
- Slack integration + cron scheduling (Week 1)
- Anomaly detection + trend analysis (Week 1)
- ROI-based ranking + risk assessment (Week 1)
- Multi-account support + savings tracker (Week 2)
- Web dashboard β Flask + Chart.js + SSE (Week 3)
- Terraform auto-remediation stubs (Week 4)
- Docker + Terraform production deployment (Week 4)
- Multi-cloud support (Azure Cost Management, GCP Billing)
- Slack slash command (
/aws-costs) for on-demand reports - Grafana dashboard integration
- GitHub Actions scheduled workflow
Nicholas Awuni β Senior DevOps / Cloud Engineer
AWS Certified Solutions Architect | HashiCorp Terraform Associate | FinOps Practitioner
"I've seen teams waste thousands on idle resources β not from negligence, but because manual cost review doesn't scale. This project makes FinOps automatic and actionable."
MIT β see LICENSE