Bird
0
0

You want to create a CloudWatch Events rule that triggers an SNS topic only when an EC2 instance changes state to either "pending" or "shutting-down". Which JSON event pattern correctly achieves this?

hard📝 Application Q9 of 15
AWS - CloudWatch
You want to create a CloudWatch Events rule that triggers an SNS topic only when an EC2 instance changes state to either "pending" or "shutting-down". Which JSON event pattern correctly achieves this?
A{"source": ["aws.ec2"], "detail-type": ["EC2 Instance State-change Notification"], "detail": {"status": ["pending", "shutting-down"]}}
B{"source": ["aws.ec2"], "detail-type": ["EC2 Instance State-change Notification"], "detail": {"state": ["running", "stopped"]}}
C{"source": ["aws.ec2"], "detail-type": ["EC2 Instance Launch Notification"], "detail": {"state": ["pending", "shutting-down"]}}
D{"source": ["aws.ec2"], "detail-type": ["EC2 Instance State-change Notification"], "detail": {"state": ["pending", "shutting-down"]}}
Step-by-Step Solution
Solution:
  1. Step 1: Confirm correct event source and detail-type

    Source must be "aws.ec2" and detail-type "EC2 Instance State-change Notification" for state changes.
  2. Step 2: Verify the detail key and values

    The key must be "state" with values "pending" and "shutting-down" to match the required states.
  3. Final Answer:

    Event pattern with "state" key and values "pending", "shutting-down" -> Option D
  4. Quick Check:

    Use "state" key with correct states for filtering [OK]
Quick Trick: Use "state" key, not "status", for EC2 state filters [OK]
Common Mistakes:
MISTAKES
  • Using wrong detail-type like "Launch Notification"
  • Using incorrect key "status" instead of "state"
  • Filtering for unrelated states

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes