An application team wants to automatically reboot an Amazon EC2 instance when a custom application metric, `TransactionFailureRate`, exceeds a threshold. A SysOps Administrator configures a CloudWatch alarm to monitor this metric. The administrator needs to trigger the `AWS-RestartEC2Instance` Systems Manager (SSM) Automation runbook when the alarm enters the ALARM state, but finds that CloudWatch alarms cannot directly target SSM Automation runbooks. Which configuration should the administrator use to achieve this goal?
- AEnable detailed monitoring on the EC2 instance to allow the CloudWatch alarm to directly target the Systems Manager Automation runbook.
- Create an Amazon EventBridge rule that triggers when the CloudWatch alarm state changes to ALARM, and specify the Systems Manager Automation runbook as the target.Answer
- CConfigure the CloudWatch alarm to send an Amazon Simple Queue Service (Amazon SQS) message to a queue, and configure the Systems Manager Automation runbook to poll the queue.
- DConfigure an Auto Scaling group cooldown period on the EC2 instance to pause metric collection while the Systems Manager Automation runbook is executing.
Answer
Create an Amazon EventBridge rule that triggers when the CloudWatch alarm state changes to ALARM, and specify the Systems Manager Automation runbook as the target.
The correct configuration uses Amazon EventBridge to bridge the gap because CloudWatch alarms cannot directly target Systems Manager Automation runbooks. When a CloudWatch alarm changes state, it emits an event to the default EventBridge event bus. An EventBridge rule can match this state change event (e.g., transition to ALARM) and trigger the Systems Manager Automation runbook (AWS-RestartEC2Instance) to reboot the target EC2 instance.
Step-by-Step Solution
Key Concept
Integrating CloudWatch Alarms with Systems Manager Automation using EventBridge