An organization wants to automatically stop idle Amazon EC2 instances to reduce costs. A SysOps administrator configures an Amazon CloudWatch alarm that transitions to the ALARM state when CPU utilization remains below for 1 hour. The administrator then creates an Amazon EventBridge rule that detects the CloudWatch alarm state change and targets an AWS Systems Manager (SSM) Automation document using the `AWS-StopEC2Instance` template. During testing, the CloudWatch alarm enters the ALARM state, but the EC2 instance is not stopped. The EventBridge dead-letter queue (DLQ) indicates a delivery failure due to an authorization issue. Which action will resolve this issue?
- AConfigure the CloudWatch alarm to trigger an Amazon CloudWatch Logs subscription filter that executes the SSM Automation document directly.
- Add the iam:PassRole permission to the EventBridge rule's IAM execution role to allow it to pass the SSM Automation execution role to Systems Manager.Answer
- CEnable detailed monitoring on the target EC2 instances to ensure CloudWatch metrics are evaluated at 1-minute intervals.
- DModify the trust policy of the SSM Automation execution role to allow the EC2 service principal to assume the role.
Answer
Add the iam:PassRole permission to the EventBridge rule's IAM execution role to allow it to pass the SSM Automation execution role to Systems Manager.
The correct option is to add the `iam:PassRole` permission to the EventBridge rule's execution role. When an EventBridge rule triggers an AWS Systems Manager Automation document that requires an execution role, the EventBridge rule's role must have the `iam:PassRole` permission to pass that execution role to Systems Manager. Without this permission, EventBridge cannot initiate the automation execution, resulting in an authorization error in the DLQ.
Step-by-Step Solution
Key Concept
Configuring correct IAM permissions, specifically iam:PassRole, for event-driven targets like AWS Systems Manager Automation in EventBridge.