[英]AWS Send SNS message from lambda at a specified time
I have a lambda function lambda1
that gets triggered by an API call and computes the parameters for another job downstream that will be handled by a different function lambda2
. I have a lambda function
lambda1
that gets triggered by an API call and computes the parameters for another job downstream that will be handled by a different function lambda2
.
The resources required to complete the downstream job are not available immediately and will become available at some future time datetime1
which is also calculated by lambda1
.完成下游作业所需的资源不会立即可用,并且将在未来某个时间
datetime1
可用,该时间也由lambda1
计算。
How do I make lambda1
schedule a message in an SNS topic that will be sent out at datetime1
instead of going out immediately?如何让
lambda1
在 SNS 主题中安排一条消息,该消息将在datetime1
发送而不是立即发送? The message sent out at the correct time will then trigger lambda2
which will find all the resources in place and execute correctly.在正确时间发出的消息将触发
lambda2
,它会找到所有资源并正确执行。
Is there a better way of doing this instead of SNS?有没有更好的方法来代替 SNS?
Both lambda1
and lambda2
are written in Python 3.8 lambda1
和lambda2
都是用 Python 3.8 编写的
You would be better off using the AWS Step Functions.最好使用 AWS Step Functions。 Step functions are generally used for orchestrating jobs with multiple Lambda functions involved and they support the
wait state
that you need to run a job at a specific time. Step 函数通常用于编排涉及多个 Lambda 函数的作业,它们支持您需要在特定时间运行作业的
wait state
。
Basically, you will create multiple states.基本上,您将创建多个状态。 One of the states will be
wait state
where you will input the wait condition (timestamp at which it will stop waiting).其中一种状态是
wait state
,您将在其中输入等待条件(它将停止等待的时间戳)。 This is what you will send from Lambda1.这是您将从 Lambda1 发送的内容。 The next state would be
task state
which will be your Lambda2.下一个 state 将是
task state
,它将是您的 Lambda2。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.