Which solution will meet this requirement in the MOST operationally efficient manner?
Implement a cron job on each EC2 instance to run once every 60 minutes and calculate the current CPU utilization. Initiate an instance shutdown if CPU utilization is less than 10%.
Implement an Amazon CloudWatch alarm for each EC2 instance to monitor average CPU utilization. Set the period at 1 hour, and set the threshold at 10%. Configure an EC2 action on the alarm to stop the instance.
Install the unified Amazon CloudWatch agent on each EC2 instance, and enable the Basic level predefined metric set. Log CPU utilization every 60 minutes, and initiate an instance shutdown if CPU utilization is less than 10%.
Use AWS Systems Manager Run Command to get CPU utilization from each EC2 instance every 60 minutes. Initiate an instance shutdown if CPU utilization is less than 10%.
Explanations:
A cron job would require manually configuring each EC2 instance, which introduces operational overhead and is not efficient for scaling. Additionally, this method doesn’t leverage AWS-native monitoring tools.
Amazon CloudWatch alarms are the most efficient solution for monitoring and automatically triggering actions. Setting the alarm to monitor CPU utilization with a threshold and configuring an EC2 action to stop the instance automates the process with minimal overhead.
Installing the unified CloudWatch agent adds unnecessary complexity. The agent is useful for custom metrics but is not required for this simple CPU utilization monitoring and shutdown task. This solution increases operational overhead compared to using CloudWatch alarms.
AWS Systems Manager Run Command requires manual configuration to query CPU utilization, and using it every 60 minutes introduces unnecessary complexity. This solution doesn’t provide the same level of efficiency and automation as CloudWatch alarms.