从Lambda在AWS EventBridge中动态调度事件



我有以下两个等价的lambda函数:

setNotification(日期,文本(:

exports.lambdaHandler = async (event, context) => {
const params = {
Entries: [
{
Source: "com.aws.message-event-lambda",
EventBusName: "",
DetailType: "message",
Detail: JSON.stringify({
title: event.detail.title,
text: event.detail.text,
}),
},
],
};
await eventbridge.putEvents(params).promise();
};

sendNotification(文本(

目前,我正在使用事件桥从setNotification函数中触发sendNotification函数,但它会立即触发函数。

如何在setNotification函数定义的特定日期触发sendNotification函数?

目前我看到以下2个选项:

  1. 在setNotification函数中创建代码,该函数在EventBridge上创建计划规则
  2. 停止使用EventBridge并使用步骤函数

我想知道这两者之间的正确方法是什么,或者是否有我还没有找到的更好的方法。

我发现,您需要一个不同的体系结构,包括一个由事件桥上的cron表达式调用的lambda函数,该函数检查DB中的条目,然后向其发送通知。

有关AWS调度系统的更多信息,请访问以下链接:

https://aws.amazon.com/blogs/architecture/serverless-scheduling-with-amazon-eventbridge-aws-lambda-and-amazon-dynamodb/

最新更新