简体   繁体   English

在单个 S3 object 上传事件上触发多个 lambda

[英]Trigger multiple lambda on single S3 object upload event

I have setup a S3 event on my bucket that triggers a lambda to resize images.我在我的存储桶上设置了一个 S3 事件,该事件触发 lambda 来调整图像大小。 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. 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:这是执行此操作的示例代码 lambda nodejs:

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.但我的要求是在一个 S3 事件(上传对象)上触发 2 个 lambda - 一个图像调整大小,另一个将图像元数据存储回 RDS。

But currently the S3 event doesn't support multiple lambda trigger.但目前 S3 事件不支持多个 lambda 触发器。 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.我看到了一个使用 SNS 然后发送到多个 lambdas 的实现,但我不想使用那个因为在这种情况下我需要更改我当前的架构。

So let me know or show some other implementations or suggestions.所以让我知道或展示一些其他的实现或建议。

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.最近发布的带有 Amazon EventBridge 的 Amazon S3 事件通知可让您使用触发多个 lambda 关闭存储桶事件,并具有重播和存档等优点。

Or, you could stick with S3 Notifications and chain the lambda calls: S3 -> lambda1 -> lambda2 .或者,您可以坚持使用 S3 通知并链接 lambda 调用: S3 -> lambda1 -> lambda2 Yuck.呸。 Or use a Step Function S3 -> lambda -> Sfn -> lambda1 + lambda2 .或使用步骤 Function S3 -> lambda -> Sfn -> lambda1 + lambda2 Double yuck.双呸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM