Which solution will meet this requirement with the MOST operational efficiency?
Configure an AWS Lambda function with an SMTP client library. Subscribe the Lambda function to the AWS Health Dashboard to receive notification whenever an EC2 instance is in the running state. Configure the Lambda function to use Amazon Pinpoint to send email notifications to the IT manager. Deploy a second Lambda function to throttle calls from the first Lambda function during the daytime.
Deploy an AWS Lambda function that queries the Amazon EC2 API to determine the state of each EC2 instance. Use the EC2 instance scheduler to configure the Lambda function to run every minute during the night and to send an email notification to the IT manager for each non-production EC2 instance that is in the running state.
Create an Amazon EventBridge rule that includes the EC2 Instance State-change Notification event type. Filter the event to capture only the running state. Create an AWS Lambda function as a target of the rule. Configure the Lambda function to check the current time and the EC2 instances’ tags to determine the environment type. Create an Amazon Simple Notification Service (Amazon SNS) topic as a target of the Lambda function for notifications. Subscribe the IT manager’s email address to the SNS topic.
Store the EC2 instance metadata, including the environment type, in an Amazon DynamoDB table. Deploy a custom application to an EC2 instance. Configure the custom application to poll the DynamoDB data every minute during the night and to query the Amazon EC2 API to determine the state of each instance. Additionally, configure the custom application to send an email notification to the IT manager for each non-production EC2 instance that is in the running state.
Explanations:
AWS Health Dashboard is not suitable for this use case; it focuses on service health, not instance state changes. Additionally, this solution adds unnecessary complexity by introducing throttling with a second Lambda function.
Querying the EC2 API every minute using Lambda is inefficient and costly. EC2 instance scheduler is not meant for this task and does not meet the real-time notification requirement.
EventBridge can capture EC2 instance state changes in real time. Filtering by environment type tag and sending notifications via SNS is a simple, efficient, and scalable solution.
Storing EC2 metadata in DynamoDB and polling for state changes every minute is an inefficient solution that adds unnecessary complexity and operational overhead.