简体   繁体   中英

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/

Here is the workflow:

-execution starts with a JSON input. Something like {"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

-work is vended back to the worker with a token

-the worker function uses the token to generate an email using SES. The URLs in the email call either SendTaskSuccess or SendTaskFailure using the token.

The thing works beautifully! Clicking the corresponding URL in the email makes the state machine proceed to the next state or fail, respectively. My only issue is: the input provided to the manual step is overwritten by the API gateway GET. So basically, the input of the manual step is the JSON blob above, but the output is something like: "Approve link was clicked." (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. 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.

Have a look at Amazon State Language: Path

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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