Skip to content

danjamk/slack-aws-cost-guardian

Repository files navigation

Slack AWS Cost Guardian

slac-aws-cost-guardian-hero.png

AI-powered AWS cost monitoring with Slack alerts

MIT License Python 3.12 AWS CDK

Detect spending anomalies, track budgets, and get intelligent analysis delivered directly to Slack.

Features

  • Anomaly Detection - AI-powered identification of unusual spending patterns
  • Daily & Weekly Reports - Automated summaries with budget tracking and forecasts
  • Interactive Slack Alerts - Acknowledge costs as expected/unexpected directly from Slack
  • Budget Threshold Alerts - Warnings at 80% and critical alerts at 100% of budget
  • AI Analysis - Claude or GPT explains what's driving cost changes
  • @mention Bot - Ask questions like @guardian what did we spend yesterday?

Quick Start

# Clone and setup
git clone https://github.com/your-org/slack-aws-cost-guardian.git
cd slack-aws-cost-guardian
make setup

# Configure (edit .env with your Slack webhooks and API keys)
vim .env

# Deploy
source .venv/bin/activate
make deploy

# Verify
make validate

Full setup guide: docs/SETUP.md - includes Slack App configuration, bot setup, and troubleshooting.

How It Works

┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│   EventBridge   │────▶│     Lambda      │────▶│  Cost Explorer  │
│   (scheduled)   │     │   (collector)   │     │      API        │
└─────────────────┘     └────────┬────────┘     └─────────────────┘
                                 │
                                 ▼
                        ┌─────────────────┐
                        │    DynamoDB     │
                        │   (snapshots)   │
                        └────────┬────────┘
                                 │
                    ┌────────────┴────────────┐
                    ▼                         ▼
           ┌─────────────────┐       ┌─────────────────┐
           │ Anomaly Detect  │       │   LLM Analysis  │
           └────────┬────────┘       └────────┬────────┘
                    │                         │
                    └────────────┬────────────┘
                                 ▼
                        ┌─────────────────┐
                        │  Slack Alert    │◀───── User Feedback
                        │  (with buttons) │
                        └─────────────────┘

┌─────────────────┐     ┌─────────────────┐
│  Slack @mention │────▶│  Events Lambda  │────▶ Bot Response
│    or DM        │     │  (with tools)   │
└─────────────────┘     └─────────────────┘

Cost to Run

This tool costs approximately $2-8/month depending on your settings:

Component Cost Notes
Cost Explorer API ~$1.50-6/month Depends on collection frequency
Secrets Manager ~$0.40/month Per secret
DynamoDB ~$0.05/month On-demand, minimal storage
Lambda/S3 ~$0/month Free tier covers it
LLM API (optional) ~$0.30-1.00/month For AI insights

See config/config.example.yaml for detailed cost breakdown and optimization tips.

Configuration

Application Settings

Copy and customize the config file:

cp config/config.example.yaml config/config.yaml

Key settings:

  • Collection frequency - How often to fetch costs (daily recommended)
  • Budget thresholds - When to alert (80%, 100%)
  • Anomaly sensitivity - What triggers an alert ($10 change, 50% increase)

AI Context

Customize the AI's understanding of your infrastructure:

vim config/guardian-context.md
make update-context

Documentation

Common Commands

make help              # Show all commands
make deploy            # Deploy to AWS
make validate          # Verify configuration
make test-daily        # Send daily report
make logs              # Tail collector logs
make logs-events       # Tail bot logs

License

MIT License - see LICENSE for details.

About

AI-powered AWS cost monitoring with Slack alerts. Detect spending anomalies, track budgets, get intelligent analysis. Open source, serverless, ~$5/month to run.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors