1
votes

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?enter image description here

1

1 Answers

1
votes

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