[英]API Gateway is Overwriting AWS Step Functions State Output
I am following this article to implement a manual approval step for my state machine: 我正在关注本文,以为我的状态机实施手动批准步骤:
https://aws.amazon.com/blogs/compute/implementing-serverless-manual-approval-steps-in-aws-step-functions-and-amazon-api-gateway/ https://aws.amazon.com/blogs/compute/implementing-serverless-manual-approval-steps-in-aws-step-functions-and-amazon-api-gateway/
Here is the workflow: 这是工作流程:
-execution starts with a JSON input. -execution从JSON输入开始。 Something like {"instance-id":"i-xxxxxxx","action":"stop"}.
类似于{“ instance-id”:“ i-xxxxxxx”,“ action”:“ stop”}之类的东西。 The input is passed to the manual step
输入传递到手动步骤
-a lambda worker polls for activity tasks by calling GetActivityTask using the ARN of the manual step -a lambda worker通过使用手动步骤的ARN调用GetActivityTask来轮询活动任务
-work is vended back to the worker with a token -工作被带回令牌出售给工人
-the worker function uses the token to generate an email using SES. -worker函数使用令牌使用SES生成电子邮件。 The URLs in the email call either SendTaskSuccess or SendTaskFailure using the token.
电子邮件中的URL使用令牌调用SendTaskSuccess或SendTaskFailure。
The thing works beautifully! 事情做得很漂亮! Clicking the corresponding URL in the email makes the state machine proceed to the next state or fail, respectively.
单击电子邮件中的相应URL会使状态机分别进入下一个状态或失败。 My only issue is: the input provided to the manual step is overwritten by the API gateway GET.
我唯一的问题是:手动步骤提供的输入被API网关GET覆盖。 So basically, the input of the manual step is the JSON blob above, but the output is something like: "Approve link was clicked."
因此,基本上,手动步骤的输入是上面的JSON Blob,但是输出类似:“单击了批准链接”。 (the body mapping template of the integration request).
(集成请求的主体映射模板)。
So how can I make it so my manual step passes the original input as an output? 那么,如何使手动步骤将原始输入作为输出传递呢?
You should set your ApprovalState's ResultPath
in the state's description. 您应该在状态的描述中设置ApprovalState的
ResultPath
。 By default it writes to the path's 'root' ($), but you can have it write to $.whatever
by adding "ResultPath": "$.whatever"
to your state's description. 默认情况下,它写入路径的“根”($),但是您可以通过在状态描述中添加
"ResultPath": "$.whatever"
,将其写入$.whatever
。
Have a look at Amazon State Language: Path 看看Amazon State Language:Path
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.