An automated system to track, analyze, and optimize cloud infrastructure's environmental impact using AWS Cost Explorer, EventBridge, Lambda, DynamoDB, and a real-time Dashboard.
- Quick Deploy (Terraform)
- Project Overview
- Architecture
- Implementation Guide
- Prerequisites
- Repository Structure
- Getting Started
- Deployment Guide
- Validation & Testing
- Cleanup
- Contributing
- Resources
Want to skip the step-by-step sections? Deploy the entire stack in under 5 minutes:
git clone https://github.com/Atharva013/Carbon-Optimizer.git
cd Carbon-Optimizer/terraform
cp terraform.tfvars.example terraform.tfvars # edit with your region/email
terraform init && terraform applyAfter deployment, open the Dashboard URL shown in the output. For details, see the Terraform README.
β οΈ Requires Terraform β₯ 1.3 and AWS CLI v2 with configured credentials.
This project creates an automated carbon footprint optimization system by integrating AWS Cost Explorer insights with sustainability analysis through EventBridge and Lambda. The system:
- π Analyzes monthly cost and usage patterns automatically
- β»οΈ Applies industry-standard carbon emission factors
- π‘ Generates optimization recommendations to reduce environmental impact and costs
- π Sends real-time alerts when high-impact optimization opportunities are found
- ποΈ Stores historical sustainability metrics for trend analysis
- π₯οΈ Visualizes all data through a real-time web dashboard hosted on S3
Estimated Monthly Cost: $15β25 USD (Lambda, DynamoDB, S3, SNS, API Gateway)
The dashboard uses a cached billing snapshot architecture so regular page refreshes do not keep calling AWS Cost Explorer.
Flow summary:
- EventBridge runs the analyzer Lambda on a schedule.
- The analyzer reads AWS billing/config data, computes carbon insights, and stores a snapshot in DynamoDB.
- SNS sends alert emails when the configured threshold or recommendation rules are triggered.
- The dashboard API reads the cached DynamoDB snapshot, and S3/CloudFront serve the UI over HTTP/HTTPS.
| Section | Responsibility |
|---|---|
| Section 1 | IAM Roles & DynamoDB Setup |
| Section 2 | Lambda Function Development |
| Section 3 | SNS Notifications & EventBridge Schedules |
| Section 4 | Cost & Usage Reports + SSM Configuration |
| Section 5 | Real-Time Dashboard & GUI |
| Section 6 | Validation, Testing & Cleanup |
β οΈ Sections must be deployed in order (1 β 2 β 3 β 4 β 5 β 6). Each section depends on the previous.
Before starting, ensure you have:
- AWS account with billing/cost management permissions
- AWS CLI v2 installed and configured (
aws --version) - Python 3.11+ installed
- Git installed and configured
- GitHub account with repo access
- IAM permissions for: Lambda, EventBridge, Cost Explorer, S3, DynamoDB, SNS, SSM, CUR, API Gateway
carbon-optimizer/
βββ README.md # This file
βββ CONTRIBUTING.md # Contribution guidelines
βββ CHANGELOG.md # Version history
βββ .gitignore # Ignored files
β
βββ terraform/ # β‘ One-command deploy (recommended)
β βββ main.tf # All AWS resources
β βββ variables.tf # User configuration
β βββ outputs.tf # Dashboard URL & endpoints
β βββ terraform.tfvars.example # Example config (copy to .tfvars)
β βββ README.md # Terraform quick-start guide
β
βββ sections/ # Per-member task breakdowns
β βββ section-1-iam-dynamodb.md
β βββ section-2-lambda.md
β βββ section-3-sns-eventbridge.md
β βββ section-4-cur-ssm.md
β βββ section-5-dashboard.md
β βββ section-6-testing-cleanup.md
β
βββ docs/ # Project documentation
β βββ github-project-setup.md
β
βββ lambda-function/ # Lambda source code
β βββ index.py # Carbon footprint analyzer
β
βββ dashboard/ # Dashboard source (Section 5)
β βββ index.html # Main dashboard UI
β βββ dashboard-api/
β βββ index.py # API Gateway Lambda
β
βββ iam/ # IAM policy documents
β βββ lambda-trust-policy.json
β βββ lambda-permissions-policy.json
β
βββ cloudformation/ # CloudFormation templates
β βββ sustainable-infrastructure.yaml
β
βββ scripts/ # Shell deploy scripts (manual path)
β βββ setup.sh # Initial resource creation
β βββ deploy-analyzer.sh # Analyzer Lambda packaging + deploy
β βββ deploy.sh # SNS + EventBridge + CUR + SSM
β βββ deploy-dashboard.sh # Dashboard Lambda + API + S3
β βββ deploy-cloudfront.sh # Optional HTTPS via CloudFront
β βββ validate.sh # End-to-end validation
β βββ cleanup.sh # Delete all resources
β
βββ .github/
βββ workflows/
β βββ validate.yml
βββ ISSUE_TEMPLATE/
βββ bug_report.md
git clone https://github.com/Atharva013/Carbon-Optimizer.git
cd Carbon-Optimizer# Set your AWS region and account
export AWS_REGION=$(aws configure get region)
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
# Set project name (use the same suffix across all sessions!)
export PROJECT_NAME="carbon-optimizer-cloud"
export S3_BUCKET="${PROJECT_NAME}-data"
export LAMBDA_FUNCTION="${PROJECT_NAME}-analyzer"
export DYNAMODB_TABLE="${PROJECT_NAME}-metrics"
echo "Project: ${PROJECT_NAME}"sections/section-1-iam-dynamodb.mdsections/section-2-lambda.mdsections/section-3-sns-eventbridge.mdsections/section-4-cur-ssm.mdsections/section-5-dashboard.mdsections/section-6-testing-cleanup.md
cd terraform
cp terraform.tfvars.example terraform.tfvars # edit with your values
terraform init
terraform applySee terraform/README.md for full details.
Run sections in order (Sections 1β5 deploy; Section 6 validates):
# Optional: create a local env file for convenience
cp .env.example .env
source .env # or export vars manually
# Full deployment
bash scripts/setup.sh # IAM + DynamoDB + S3
bash scripts/deploy-analyzer.sh # Analyzer Lambda
bash scripts/deploy.sh # SNS + EventBridge + CUR + SSM
bash scripts/deploy-dashboard.sh # Dashboard Lambda + API Gateway + S3 upload
# Trigger one fresh billing snapshot for the dashboard
aws lambda invoke --function-name ${PROJECT_NAME}-analyzer --payload '{}' /tmp/r.json && cat /tmp/r.json
# Optional: HTTPS via CloudFront (takes 5-10 minutes)
bash scripts/deploy-cloudfront.sh# Test Lambda execution
aws lambda invoke \
--function-name ${LAMBDA_FUNCTION} \
--payload '{}' response.json && cat response.json
# Verify DynamoDB data
aws dynamodb scan --table-name ${DYNAMODB_TABLE} --max-items 5
# List EventBridge schedules
aws scheduler list-schedules --name-prefix ${PROJECT_NAME}
# Run full validation suite (Section 6)
bash scripts/validate.sh# If deployed with Terraform:
cd terraform && terraform destroy
# If deployed with shell scripts:
bash scripts/cleanup.sh
β οΈ This permanently deletes all AWS resources created by this project.
See CONTRIBUTING.md for branch naming, commit conventions, and PR process.
Branch naming for each section:
feature/section-1-iam-dynamodb
feature/section-2-lambda
feature/section-3-sns-eventbridge
feature/section-4-cur-ssm
feature/section-5-dashboard
feature/section-6-testing-cleanup
