Catching a Silent AWS Failure: A Serverless Daily Report for Suspended Auto Scaling Groups
Catching a Silent AWS Failure: A Serverless Daily Report for Suspended Auto Scaling Groups How I built a zero-cost, zero-server monitoring alert with Lambda, EventBridge, and SES, and the two production bugs I hit along the way. The silent failure nobody watches Amazon EC2 Auto Scaling Groups (ASGs) have a feature that's incredibly useful during incidents and quietly dangerous afterward: you can…
Title: Catching a Silent AWS Failure: A Serverless Daily Report for Suspended Auto Scaling Groups
A zero-cost, serverless monitoring alert was created using Amazon EventBridge, AWS Lambda, and Amazon SES to track suspended Auto Scaling Groups (ASGs) in AWS. ASGs have a feature that suspends processes such as Launch, Terminate, HealthCheck, and AZRebalance, which can be useful during incidents and dangerous afterward if forgotten to resume.
The architecture consists of EventBridge triggering a Python Lambda function daily to scan all ASGs across configured regions, filtering for suspended processes, and then sending an HTML report via SES. No servers, agents, or cron boxes are required to maintain.
The core logic of the Lambda function uses the boto3 client to describe all ASGs and a paginator to handle groups with many ASGs. Only ASGs with suspended processes are added to a list, which is then converted to an HTML table and sent via SES.
The report email features each affected ASG, the suspended processes, and the min/desired/max capacity. There is also an option to email only when something is wrong or a daily all-clear notification.
During deployment, two bugs were encountered:
1. Runtime.ImportModuleError: No module named 'lambda_function': This occurred because the Lambda handler setting was still pointing to the default lambda_function.lambda_handler, while the actual code was in handler.py with a function named handler. The fix was to update the Lambda configuration to use the correct handler string, which is 'file.function'.
2. AccessDenied on autoscaling:DescribeAutoScalingGroups: The execution role had a basic trust policy but was missing the necessary permissions to describe ASGs. The fix was to add an inline policy to the execution role, allowing the 'autoscaling:DescribeAutoScalingGroups' action and 'ses:SendEmail' and 'ses:SendRawEmail' actions for SES.
Overall, this serverless solution provides a zero-cost, reliable way to monitor suspended ASGs daily and receive alerts via email, helping to prevent production issues caused by forgotten scaling process resumptions.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.