How shungok/rds_stopper works
Project type and purpose
• This is a serverless, event-driven automation tool whose sole purpose is to stop AWS RDS instances and clusters on a daily schedule, provided they carry a specific tag.
File structure
• Top-level files:
• README.md – project overview, install & usage
• lambda/main.py – the Lambda function code that contains the logic to list, filter by tag, and stop RDS resources
• serverless/serverless.yml – Serverless Framework service definition, provider (AWS), function definitions, IAM role statements, environment variables (e.g., TARGET_TAG)
• serverless/events/main.yml – CloudWatch Events Rule definition that invokes the Lambda on a schedule (cron at 00:00 UTC)
README for additional insights
• Core AWS services used: Lambda (Python 3.7 + boto3), CloudWatch Events (for scheduling), RDS (DB instances & clusters)
• The Serverless Framework is the deployment mechanism
Main components & interactions
a. Components
• CloudWatch Events Rule (scheduled trigger at 0:00 UTC daily)
• AWS Lambda function (main.py)
• AWS RDS (DB Instances & Clusters)
• IAM Role / Permissions (attached to the Lambda)
• Serverless Framework (deployment layer – optional to show)
b. Relationships & data flow
1. CloudWatch Events → triggers → Lambda
2. Lambda (using IAM role permissions) → Describe/List → AWS RDS
3. Lambda → Stop DB Instances/Clusters API calls → AWS RDS
4. Lambda → Logs → CloudWatch Logs
c. Architectural patterns & design principles
• Event-driven serverless architecture
• Single-purpose function (the lambda only handles “stop” logic)
• Infrastructure-as-Code via Serverless Framework
• Tag-based resource selection (extensibility: change tag key/value via environment variable)
d. Technologies/frameworks/libraries
• AWS Lambda (Python 3.7, boto3 1.9.42)
• AWS CloudWatch Events
• AWS RDS API
• Serverless Framework v1.36.3
Be detailed—capture each piece
• IAM role with the minimum permissions (rds:Describe*, rds:Stop*, logs:CreateLogStream, logs:PutLogEvents)
• Call out the TARGET_TAG env var from serverless.yml that drives which RDS resources get stopped
Final recommendation:
[Serverless Framework (deploy)]
↓
[CloudWatch Events Rule (cron)] → [Lambda Function (main.py + TARGET_TAG env)] ––> [AWS RDS: Instances & Clusters]
↘
→ [CloudWatch Logs]