AWS SQS 触发器 Step Functions

AWS SQS trigger Step Functions

小问题:发送 SQS 消息后是否可以触发 Step Function 的执行?如果可以,您将如何将其指定到 cloudformation yaml 文件中?

提前致谢。

首先要考虑的是:您真的需要使用SQS来启动Step Functions状态机吗?你能use API gateway instead? Or could you write your messages to a S3 bucket and use the CloudWatch events to start a state machine吗?

如果您必须使用 SQS,那么您将需要一个 lambda 函数来充当代理。您将需要 set up the queue as a lambda trigger, and you will need to write a lambda that can parse the SQS message and make the appropriate call to the Step Functions StartExecution API

我在手机上,所以我现在不能输入yaml,但如果你需要,我可以稍后尝试更新。现在,这里是如何 invoke a Step Functions state machine from Lambda (including example yaml), and here is walkthrough of how to use CloudFormation to set up SQS to trigger a Lambda 的详细演练。