DVA-C02 Question 36
Select 2You are developing an AWS Lambda function to process data from an Amazon S3 bucket. The function should trigger whenever a new object is uploaded to the bucket. You also need to ensure that the function has the necessary permissions to read from the bucket. Which of the following steps are required to achieve this setup?
- A
Create an Event Notification on the S3 bucket to trigger the Lambda function on the 's3:ObjectCreated:*' event.
- B
Attach an IAM policy to the Lambda function's execution role that allows the 's3:GetObject' permission for the S3 bucket.
- C
Configure the Lambda function to poll the S3 bucket for new objects every minute.
- D
Add an Event Bridge rule to trigger the Lambda function whenever an object is created in the S3 bucket.
- E
Ensure the S3 bucket policy allows 's3:PutObject' permission for the Lambda function.
Show answer and explanation
Correct answers: A, B
Explanation
To process new objects in an S3 bucket using Lambda, you need to configure an Event Notification on the S3 bucket for the 's3:ObjectCreated:*' event and ensure the Lambda function's execution role has the 's3:GetObject' permission to read the objects. Polling the bucket or using EventBridge is unnecessary, and 's3:PutObject' permission is irrelevant in this context unless the Lambda function needs to upload objects.
- A. Correct.
Correct: An Event Notification on the S3 bucket is required to trigger the Lambda function on the 's3:ObjectCreated:*' event.
- B. Correct.
Correct: The Lambda function's execution role must have the 's3:GetObject' permission to read data from the S3 bucket.
- C. Incorrect.
Incorrect: AWS Lambda cannot poll an S3 bucket; instead, S3 Event Notifications are used to trigger Lambda functions.
- D. Incorrect.
Incorrect: EventBridge rules are not used to trigger Lambda functions directly from S3 events. S3 Event Notifications handle this integration.
- E. Incorrect.
Incorrect: The S3 bucket does not need 's3:PutObject' permission for the Lambda function in this scenario because the Lambda function is not uploading objects to the bucket.