AWS Certified Cloud Practitioner / Question #1221 of 719

Question #1221

A user needs to execute an AWS Lambda function whenever an Amazon EC2 instance transitions to the “terminated” state. Which AWS service should be used to accomplish this?

A

Amazon EventBridge

B

AWS Config

C

Amazon Simple Notification Service (Amazon SNS)

D

AWS CloudFormation

Explanation

Amazon EventBridge (A) is designed to respond to AWS service events, such as EC2 instance state transitions. When an EC2 instance is terminated, EventBridge detects this event and can invoke a Lambda function automatically.

Other options are incorrect because:
- AWS Config (B): Tracks resource configuration changes but does not trigger actions in real-time for events like instance termination.
- Amazon SNS (C): Requires manual setup to publish termination events (e.g., via EventBridge), making it an indirect solution.
- AWS CloudFormation (D): Manages infrastructure deployment but does not handle runtime event-based triggers.

Key Point: EventBridge natively integrates with EC2 state changes and Lambda, making it the simplest and most direct solution.

Answer

The correct answer is: A