Monitoring and Logging

An operations team needs SNS notifications for EC2 Instance State-change Notification events only when either of two designated instances enters stopped or terminated. How should an EventBridge rule's event pattern combine the instance IDs and states?

Show the answer

Correct answerA. Place both IDs in detail.instance-id and both states in detail.state within one pattern.

AWhy this is right: Values within each array are alternatives, while the instance-id and state fields must both match.

BWhy not this: EC2 state-change events identify the instance in detail.instance-id; their resources array is empty.

CWhy not this: Separate $or branches allow a matching instance ID or a matching state instead of requiring both conditions.

DWhy not this: EventBridge matches event structure, and these EC2 fields are nested under detail rather than at the top level.

EventBridge uses OR between values in a field's array and AND between different fields, so one pattern matches either designated instance in either specified state. A top-level $or between the ID and state conditions would also match unrelated instances entering those states.