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:
next:
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.
CodePudding user response:
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