# bhumii23/aws-cost-optimiztion architecture

> Architecture diagram of the GitHub repository bhumii23/aws-cost-optimiztion, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhumii23/aws-cost-optimiztion
- Repository: https://github.com/bhumii23/aws-cost-optimiztion

## Overview

This is a scheduled AWS cost-optimization Lambda. EventBridge triggers a run that evaluates EBS snapshots against cleanup and protection rules, then reports estimated savings; the same product also analyzes EC2 utilization and produces right-sizing and generation-upgrade recommendations. CloudWatch supplies monitoring and reporting. The excerpts show the handler’s AWS client setup, safety checks, deletion, and recommendation logic, but omit parts of the handler; README-supported capabilities are included without inferring unshown call details.

Main entry points: [`lambda_function.py`](https://github.com/bhumii23/aws-cost-optimiztion/blob/main/lambda_function.py) (Lambda handler), [`config.py`](https://github.com/bhumii23/aws-cost-optimiztion/blob/main/config.py) (Optimization settings), [`cloudwatch-dashboard.json`](https://github.com/bhumii23/aws-cost-optimiztion/blob/main/cloudwatch-dashboard.json) (Dashboard and alarms)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Scheduled Runtime"]
  node_lambda["Lambda handler<br/>[lambda_function.py]"]
  node_config["Optimization settings<br/>[config.py]"]
end

subgraph group_snapshots["Snapshot Optimization"]
  node_snapshot_scan["Snapshot scan<br/>[lambda_function.py]"]
  node_safety["Safety filters<br/>[lambda_function.py]"]
  node_snapshot_delete["Snapshot deletion<br/>[lambda_function.py]"]
  node_ec2_api["EC2 API"]
end

subgraph group_compute["EC2 Recommendations"]
  node_recommendations["EC2 analysis<br/>[lambda_function.py]"]
end

subgraph group_observability["Cost Reporting"]
  node_cloudwatch[("CloudWatch")]
  node_savings["Savings summary<br/>[lambda_function.py]"]
  node_dashboard["Dashboard and alarms"]
end

node_eventbridge(("EventBridge schedule"))

node_eventbridge -->|"triggers"| node_lambda
node_lambda -->|"runs"| node_snapshot_scan
node_snapshot_scan -->|"scans snapshots"| node_ec2_api
node_snapshot_scan -->|"checks candidates"| node_safety
node_safety -->|"reads rules"| node_config
node_safety -->|"allows deletion"| node_snapshot_delete
node_snapshot_delete -->|"deletes snapshots"| node_ec2_api
node_lambda -->|"analyzes instances"| node_recommendations
node_recommendations -->|"reads CPU metrics"| node_cloudwatch
node_recommendations -->|"uses thresholds and pricing"| node_config
node_lambda -->|"summarizes savings"| node_savings
node_savings -->|"publishes metrics"| node_cloudwatch
node_cloudwatch -->|"feeds monitoring"| node_dashboard

click node_lambda "https://github.com/bhumii23/aws-cost-optimiztion/blob/main/lambda_function.py"
click node_snapshot_scan "https://github.com/bhumii23/aws-cost-optimiztion/blob/main/lambda_function.py"
click node_safety "https://github.com/bhumii23/aws-cost-optimiztion/blob/main/lambda_function.py"
click node_snapshot_delete "https://github.com/bhumii23/aws-cost-optimiztion/blob/main/lambda_function.py"
click node_config "https://github.com/bhumii23/aws-cost-optimiztion/blob/main/config.py"
click node_recommendations "https://github.com/bhumii23/aws-cost-optimiztion/blob/main/lambda_function.py"
click node_savings "https://github.com/bhumii23/aws-cost-optimiztion/blob/main/lambda_function.py"
click node_dashboard "https://github.com/bhumii23/aws-cost-optimiztion/blob/main/cloudwatch-dashboard.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_lambda,node_config toneBlue
class node_snapshot_scan,node_safety,node_snapshot_delete,node_ec2_api toneAmber
class node_recommendations toneMint
class node_cloudwatch,node_savings,node_dashboard toneRose
class node_eventbridge toneIndigo
```

## Components

### Scheduled Runtime

- [Lambda handler](https://github.com/bhumii23/aws-cost-optimiztion/blob/main/lambda_function.py): `lambda_function.py`
- [Optimization settings](https://github.com/bhumii23/aws-cost-optimiztion/blob/main/config.py): `config.py`

### Snapshot Optimization

- [Snapshot scan](https://github.com/bhumii23/aws-cost-optimiztion/blob/main/lambda_function.py): `lambda_function.py`
- [Safety filters](https://github.com/bhumii23/aws-cost-optimiztion/blob/main/lambda_function.py): `lambda_function.py`
- [Snapshot deletion](https://github.com/bhumii23/aws-cost-optimiztion/blob/main/lambda_function.py): `lambda_function.py`
- **EC2 API**

### EC2 Recommendations

- [EC2 analysis](https://github.com/bhumii23/aws-cost-optimiztion/blob/main/lambda_function.py): `lambda_function.py`

### Cost Reporting

- **CloudWatch**
- [Savings summary](https://github.com/bhumii23/aws-cost-optimiztion/blob/main/lambda_function.py): `lambda_function.py`
- [Dashboard and alarms](https://github.com/bhumii23/aws-cost-optimiztion/blob/main/cloudwatch-dashboard.json): `cloudwatch-dashboard.json`

### Other components

- **EventBridge schedule**

## Connections

- EventBridge schedule → Lambda handler: triggers (evidence: `Readme.md`)
- Lambda handler → Snapshot scan: runs (evidence: `Readme.md`)
- Snapshot scan → EC2 API: scans snapshots (evidence: `Readme.md`)
- Snapshot scan → Safety filters: checks candidates (evidence: `lambda_function.py`)
- Safety filters → Optimization settings: reads rules (evidence: `lambda_function.py`)
- Safety filters → Snapshot deletion: allows deletion (evidence: `lambda_function.py`)
- Snapshot deletion → EC2 API: deletes snapshots (evidence: `lambda_function.py`)
- Lambda handler → EC2 analysis: analyzes instances (evidence: `Readme.md`)
- EC2 analysis → CloudWatch: reads CPU metrics (evidence: `Readme.md`)
- EC2 analysis → Optimization settings: uses thresholds and pricing (evidence: `lambda_function.py`)
- Lambda handler → Savings summary: summarizes savings (evidence: `lambda_function.py`)
- Savings summary → CloudWatch: publishes metrics (evidence: `Readme.md`)
- CloudWatch → Dashboard and alarms: feeds monitoring (evidence: `Readme.md`)
