How to invoke lambda function from S3 bucket

This article explains how to trigger a lambda function on S3 event notifications . Amazon S3 supports several event notification types and destinations where the notifications can be published. In this article we will be focusing on Lambda Function as an event destination.

Trigger Lambda function on S3 Object Create Events

1. Navigate to Amazon S3 console at https://console.aws.amazon.com/s3/ .

s3 console

2. Select S3 bucket to invoke lambda functions on create object event.

3. Click on Properties tab.

s3 event notification

4. Scroll down to Event notifications section.

s3 event notification

5. Click on Create event notifications and enter Event name.

s3 event notification

6. Select Event types for which you want to invoke the lambda function.

s3 event notification

7. Scroll down to Destination section, select Lambda Function to trigger on events and click on Save changes.

s3 event notification

Verify Lambda Invocation from s3 bucket

1. Upload any test file to the configured S3 bucket.

2. Navigate to CloudWatch.

cloudwatch

3. Navigate to Log groups for selected lambda function.

log group

4. Validate lambda invocation with entry in Log Streams.


Category: AWS