AWS Certified Developer – Associate (DVA-C02)DeploymentEasy
A developer is building an application that needs to receive real-time notifications about changes to objects in an Amazon S3 bucket. They want to trigger an AWS Lambda function whenever a new object is created in a specific S3 prefix. Which method should the developer use to configure this event notification?
- AConfigure an S3 event notification directly on the bucket
- BCreate an Amazon SNS topic and publish S3 events to it
- CSet up an Amazon CloudWatch Event Rule for S3
- DUse an AWS Step Functions state machine to poll S3
Show answer & explanationAnswer & explanation
Correct answer: A. Configure an S3 event notification directly on the bucket
Amazon S3 buckets have a native capability to send event notifications directly to AWS Lambda functions, Amazon SNS topics, or Amazon SQS queues when specific object actions (like creation or deletion) occur.
Why the other options are wrong
- B. While S3 can publish to SNS, the Lambda function would still need to subscribe to the SNS topic. Direct S3 to Lambda is more direct for a single target.
- C. CloudWatch Events can monitor S3 API calls via CloudTrail, but direct S3 event notifications are simpler and more efficient for this use case.
- D. Polling S3 with Step Functions is inefficient and unnecessary when direct event notifications are available.
S3 Event Notifications
Amazon S3 can send notifications when certain events happen in your bucket. These events can trigger AWS Lambda functions, publish to Amazon SNS topics, or send messages to Amazon SQS queues.
- Triggered by object creation, deletion, restore, etc.
- Targets include Lambda, SNS, SQS.
- Can filter by prefix and suffix.
- Configured directly on the S3 bucket.
Memory trick: S3's direct line to Lambda, for every new object's chime.