Triggering Lambda on EC2 State Changes
A user wants to invoke an AWS Lambda function when an Amazon EC2 instance enters the “stopping” state. Which AWS service is appropriate for this use case?
Community Votes
100% of anonymous learners picked answer A. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
The question tests knowledge of cloud-native event routing, where the common trap is confusing general notification services with centralized event buses that handle infrastructure state changes.
Amazon EventBridge is the correct AWS service for triggering a Lambda function when an EC2 instance enters a specific state like stopping. This page explains how EventBridge enables event-driven architectures based on resource lifecycle changes.
Candidates often incorrectly choose Amazon SNS, assuming it handles all notifications; however, SNS does not natively listen to EC2 state transitions without additional configuration or layers.
Community Discussion (4 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
Amazon EventBridge (formerly CloudWatch Events) is the appropriate service because it acts as a serverless event bus that can detect state changes in AWS resources, such as an EC2 instance entering the 'stopping' state. You can create an EventBridge rule that matches this specific state change and targets an AWS Lambda function as the action. This allows for automated, event-driven workflows without manual polling.Why the Other Options Are Wrong
AWS Config tracks configuration changes and compliance over time but is not designed for real-time invocation of functions based on simple state transitions like stopping. Amazon Simple Notification Service (SNS) is a pub/sub messaging service that delivers notifications but does not inherently monitor EC2 states; it requires a source (like EventBridge or CloudWatch) to push events to it. AWS CloudFormation is an infrastructure-as-code service used for provisioning and managing resources, not for runtime event handling or automation triggers.Community Comment Notes
The community consensus strongly supports Option A, with users noting that EventBridge is specifically designed for "event-driven workflows based on state changes." One commenter referenced the official AWS knowledge center article confirming that EventBridge is the standard way to start/stop instances or trigger actions on their lifecycle. Another user simply stated, "EventBridge is for event-driven cases," reinforcing the core concept tested.Official Reference
Exam Strategy
When asked about triggering actions based on resource state changes (start, stop, terminate), immediately think of EventBridge. It is the central hub for AWS events and is the most efficient way to decouple infrastructure changes from application logic.
Frequently Asked Questions
Can I use CloudWatch Alarms instead of EventBridge?
CloudWatch Alarms are primarily for metrics (CPU, memory), not instance states. While you can create custom metrics for states, EventBridge natively listens to instance state changes via the EC2 API.
Why is SNS not the best answer here?
SNS is a notification delivery service. It doesn't know about EC2 states itself. You would typically use EventBridge to catch the state change and then publish to SNS if needed, making EventBridge the primary trigger.
Related Analysis
Practice All CLF-C02 Questions
Access 120 questions with complete answers and detailed explanations.
View Full CLF-C02 Practice Test →