Discover how to leverage AWS Trusted Advisor, Amazon SNS, and AWS Lambda to monitor and automatically terminate underutilized EC2 instances, optimizing resource utilization and reducing costs.
Table of Contents
Question
A SysOps administrator manages an AWS account where developers run CPU-intensive tasks on Amazon EC2 instances. The tasks can take several days to finish running and sometimes need to be repeated several times. The developers often forget to terminate the instances when the tasks are complete.
The SysOps administrator needs to implement a solution to monitor EC2 CPU utilization and automatically terminate underutilized instances.
Which solution will meet these requirements?
A. Configure an Amazon GuardDuty finding that is based on EC2 CPU utilization. Associate an AWS Lambda function with the GuardDuty finding to terminate any instances that are identified as idle.
B. Configure an Amazon Simple Notification Service (Amazon SNS) topic to receive EC2 utilization messages from the AWS Health Dashboard. Create an AWS Lambda function. Subscribe the Lambda function to the SNS topic. Use the ec2.stop_instances operation to terminate idle instances.
C. Configure a Low Utilization Amazon EC2 Instances check in AWS Trusted Advisor to publish status changes to an Amazon Simple Notification Service (Amazon SNS) topic. Create an AWS Lambda function. Subscribe the Lambda function to the SNS topic. Use the ec2.stop_instances operation to terminate idle instances.
D. Configure an Amazon EventBridge rule for the Low Utilization Amazon EC2 Instances check in AWS Trusted Advisor. Select the EC2 Terminatelnstances API call as the target.
Answer
C. Configure a Low Utilization Amazon EC2 Instances check in AWS Trusted Advisor to publish status changes to an Amazon Simple Notification Service (Amazon SNS) topic. Create an AWS Lambda function. Subscribe the Lambda function to the SNS topic. Use the ec2.stop_instances operation to terminate idle instances.
Explanation
This solution leverages AWS Trusted Advisor, Amazon SNS, and AWS Lambda to monitor EC2 CPU utilization and automatically terminate underutilized instances.
Here’s how it works:
- Configure the Low Utilization Amazon EC2 Instances check in AWS Trusted Advisor. This check monitors EC2 instances and identifies those with low CPU utilization.
- Set up AWS Trusted Advisor to publish status changes for the Low Utilization Amazon EC2 Instances check to an Amazon SNS topic.
- Create an AWS Lambda function that will be triggered by notifications from the SNS topic. This Lambda function should use the ec2.stop_instances operation to terminate the underutilized instances.
- Subscribe the Lambda function to the SNS topic created in step 2.
When AWS Trusted Advisor detects EC2 instances with low CPU utilization, it will publish a notification to the SNS topic. This notification will trigger the Lambda function, which will then terminate the underutilized instances using the ec2.stop_instances operation.
This solution automates the process of identifying and terminating underutilized instances, ensuring that resources are not wasted and costs are optimized.
Other options are not suitable or do not fully address the requirements:
A. Amazon GuardDuty is a threat detection service and is not designed for monitoring EC2 CPU utilization or terminating instances.
B. Monitoring EC2 utilization messages from the AWS Health Dashboard is not a recommended approach, as the Health Dashboard is designed for monitoring AWS service status, not resource utilization.
D. Amazon EventBridge can be used to monitor AWS Trusted Advisor checks, but it cannot directly terminate EC2 instances. A Lambda function is still required to perform the termination action.
Amazon AWS Certified SysOps Administrator – Associate certification exam practice question and answer (Q&A) dump with detail explanation and reference available free, helpful to pass the Amazon AWS Certified SysOps Administrator – Associate exam and earn Amazon AWS Certified SysOps Administrator – Associate certification.