The requirement is to monitor and notify whenever a non-production EC2 instance is started during
the night. Amazon EventBridge offers a robust solution by triggering workflows in response to
events.
Setting up Amazon EventBridge: Create an EventBridge rule that listens for the "EC2 Instance State-
change Notification" event. Configure the rule to trigger only when instances transition to the
"running" state.
Lambda Function: Attach a Lambda function as the target of the EventBridge rule. This function will
execute when an EC2 instance starts. Inside the Lambda function, implement logic to check the
current time and confirm it is during the night hours. Additionally, the function will check the
instance's tags to verify if it's labeled as "non-production".
Notification via Amazon SNS: If the conditions are met (non-production and nighttime), the Lambda
function publishes a message to an Amazon SNS topic specifically set up for this alert. The IT
manager is subscribed to this topic, enabling them to receive an email notification almost
instantaneously when the event occurs.
This solution is operationally efficient as it leverages serverless components that are inherently
scalable and cost-effective, providing real-time monitoring and notifications without the need for
continuous polling or complex infrastructure.