How should the Administrator meet these requirements?
Create an Amazon CloudWatch alarm based on the CPUUtilization metric. When the metric is 0% for 24 hours, trigger an action to terminate the EC2 instance when the alarm is triggered.
Create an AWS Lambda function to check all EC2 instances and terminate instances running more than 24 hours. Trigger the function with an Amazon CloudWatch Events event every 15 minutes.
Add an action to AWS Trusted Advisor to turn off EC2 instances based on the Low Utilization Amazon EC2 Instances check, terminating instances identified by Trusted Advisor as running for more than 24 hours.
Install the unified Amazon CloudWatch agent on every EC2 instance. Configure the agent to terminate instances after they have been running for 24 hours.
Explanations:
A CloudWatch alarm based on CPUUtilization is not a reliable way to terminate EC2 instances after 24 hours. Instances could be idle with low CPU usage, but still needed for other purposes, so terminating based on CPU usage would not fulfill the requirement.
This option involves creating an AWS Lambda function to check the age of EC2 instances and terminate those running longer than 24 hours. The Lambda function can be triggered by a CloudWatch Events rule every 15 minutes, which ensures instances are terminated in a timely manner.
Trusted Advisor’s Low Utilization check identifies underutilized instances but does not offer an option to terminate EC2 instances after 24 hours of runtime. It focuses on utilization, not the duration of instance uptime.
Installing the CloudWatch agent does not provide an automatic mechanism to terminate EC2 instances after 24 hours. The agent is typically used for monitoring and logging, not for terminating instances based on uptime.