简体   繁体   English

AWS SQS 触发器 Step Functions

[英]AWS SQS trigger Step Functions

Quick question: Is it possible to trigger the execution of a Step Function after an SQS message was sent?, if so, how would you specify it into the cloudformation yaml file?快速提问:是否可以在发送 SQS 消息后触发步骤 Function 的执行?如果可以,您将如何将其指定到 cloudformation yaml 文件中?

Thanks in advance.提前致谢。

The first think to consider is this: do you really need to use SQS to start a Step Functions state machine? 首先要考虑的是:你真的需要使用SQS来启动Step Functions状态机吗? Can you use API gateway instead? 你可以使用API​​网关吗? Or could you write your messages to a S3 bucket and use the CloudWatch events to start a state machine ? 或者您可以将消息写入S3存储桶并使用CloudWatch事件启动状态机吗?

If you must use SQS, then you will need to have a lambda function to act as a proxy. 如果必须使用SQS,则需要使用lambda函数作为代理。 You will need to 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 . 您需要将队列设置为lambda触发器 ,并且您需要编写一个lambda,它可以解析SQS消息并对Step Functions StartExecution API进行适当的调用。

I'm on mobile, so I can't type up the yaml right now, but if you need it, I can try to update with it later. 我在移动设备上,所以我现在无法输入yaml,但如果你需要它,我可以尝试稍后用它更新。 For now, here is detailed walkthrough of how to 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 . 现在,这里详细介绍如何从Lambda调用步骤函数状态机 (包括示例yaml),下面是如何使用CloudFormation设置SQS来触发Lambda的演练。

EventBridge Pipes (launched at re:Invent 2022) allows you to trigger Step Functions State Machines without need for a Lambda function. EventBridge Pipes(在 re:Invent 2022 上发布)允许您触发 Step Functions State 机器,而无需 Lambda function。

https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-pipes.html https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-pipes.html

You can find an example here:你可以在这里找到一个例子:

https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/demo-trigger-stepfunctions-from-sqs/template.yaml https://github.com/aws-samples/aws-stepfunctions-examples/blob/main/sam/demo-trigger-stepfunctions-from-sqs/template.yaml

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

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