6

I have setup a S3 event on my bucket that triggers a lambda to resize images. So every time a file is placed in bucket S3, the lambda function is called, an event with information from the created file will be sent to the lambda function.

Here is an example sample of how to trigger:

enter image description here

next:

enter image description here

Here's an example code lambda nodejs to do this:

exports.handler = (event, context, callback) => {

  var lastCreatedFile = event.Records[0].s3.object.key;
  console.log(lastCreatedFile);

};

But my requirements is to trigger 2 lambda on one S3 event (upload object)- one image resize and another to store images meta data back to RDS.

But currently the S3 event doesn't support multiple lambda trigger. I saw an implementation that uses SNS and then send to multiple lambdas but I don't want to use that coz in that case I need to change my current architecture.

So let me know or show some other implementations or suggestions.

1 Answer 1

7

The recently announced Amazon S3 Event Notifications with Amazon EventBridge lets you use trigger multiple lambdas off bucket events and has goodies like replay and archiving.

Or, you could stick with S3 Notifications and chain the lambda calls: S3 -> lambda1 -> lambda2. Yuck. Or use a Step Function S3 -> lambda -> Sfn -> lambda1 + lambda2. Double yuck. [Edit]: Triple Yuck - S3 -> Lambda1 -> S3 -> Lambda2

Sign up to request clarification or add additional context in comments.

1 Comment

In addition to that, there's also an option of sending event notification to the SNS topic and subscribe Lambda functions to that topic. Problem with this approach is that the event is not the same as when it gets directly from S3 event (it has additional layer of SNS message around it)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.