amazon-web-servicestokenstate-machineaws-step-functionsaws-datasync

How to use TaskToken feature with Datasync task in a step function?


I am executing a datasync task from step function using sdk and appending waitforTaskExecution at the end. But the state keeps on running even if the datasync task is completed. I came to know about callback feature $$.Task.Token which will throw a response back to step function once the task is completed. I tried using it in the Parameters section "TaskToken.$":"$$.Task.Token" but I'm getting an error that TaskToken is not supported by Step functions. But the documentation shows same syntax.


Solution

  • With the Callback pattern (.waitForTaskToken), you are responsible for having another part of your system capture the task token, then call back to Step Functions using the SendTaskSuccess, SendTaskFailure, and / or SendTaskHearbeat API Actions. This is why the workflow execution pauses indefinitely if you have not implemented that callback.

    As for the error you see, that's because you use the Parameters block to construct the API call and the target API Action doesn't support a TaskToken field. If you want to use this pattern, you will need to find a location where you can include the token in the call, then connect that to something that will use that information to call back when complete. I think you may be better to just use the Job Poller pattern here so that Step Functions can monitor progress and completion for you.