Q30 — AWS SOA-C02 Ch.1
Question 30 of 100 | ← Chapter 1
A company decides to stop non-production Amazon EC2 instances during the night. The company's IT manager must receive notification in near real time whenever an EC2 instance that has an environment type tag value of non-production is started during the night. Which solution will meet this requirement with the MOST operational efficiency?
- A. 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.
- B. 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.
- C. 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. ✓
- D. 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.
Correct Answer: C. 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.
Explanation
这道题考察有效监控EC2实例状态变化并触发通知的架构设计,涉及AWS事件驱动服务的使用。根据AWS架构最佳实践文档,事件驱动的无服务器模式在实时性和资源效率上优于轮询方案。EventBridge可直接捕获EC2状态变化事件,避免了轮询API的开销(排除选项B/D)。Lambda函数仅在事件触发时运行,结合时间判断和标签过滤,确保仅处理夜间启动的非生产实例,减少无效执行。SNS作为托管服务处理通知逻辑,比SMTP库(选项A)或自定义应用(选项D)更可靠。选项C通过集成多个托管服务,在事件响应、资源利用和维护成本上达到最优。