DEV Community

Cloudev
Cloudev

Posted on

Automating AWS Cost Monitoring with Terraform, Lambda, and Slack

Managing cloud costs can quickly become challenging, especially when resources scale dynamically. Instead of manually checking the AWS console, I built an automated system that sends daily cost summaries directly to Slack.

Problem

AWS bills can grow unexpectedly without real-time visibility. Logging into the console daily is inefficient and easy to forget.

Solution

I built a serverless cost monitoring system using Terraform and AWS services that automatically sends cost updates to Slack.

Architecture

The system follows a simple event-driven design:

  • EventBridge triggers a Lambda function daily
  • Lambda queries AWS Cost Explorer API
  • The cost data is formatted into a readable summary
  • A Slack webhook sends the message to a channel

Tools Used

  • Terraform (latest version)
  • AWS Lambda (Python)
  • EventBridge
  • IAM (least privilege)
  • AWS Cost Explorer API
  • Slack Incoming Webhooks

How It Works

  • Every day, the Lambda function runs and retrieves:
  • Total AWS spend for the day
  • Breakdown of costs by service
  • Optional alerts if spending exceeds thresholds

It then sends a message like this to Slack:
AWS Cost Summary – 18 Mar 2026
Total Spend Today: $12.34
Top Services:

  • EC2: $6.50
  • S3: $3.20
  • Lambda: $2.64 Key Benefits
  • Automated cost visibility
  • Early detection of unexpected spikes
  • Low cost to run (within free tier for most users)
  • Fully serverless and scalable

GitHub Repository
https://github.com/Copubah/aws-cost-reporter

Top comments (0)