I am using step functions with lambdas to do callbacks using $$.Task.Token and SendTaskSuccess.
Everything works fine on the first callback. But if I need to do a second callback, I get TaskTimedOut: Task Timed Out: 'Provided task does not exist anymore'
.
I'm not sure if I should preserve the first tasktoken from $$.Task.Token or generate a new one for each callback. But it doesn't seem to matter, because I have attempted to do both and get the same result either way.
Shouldn't this be possible? Is there anything special I have to do?
The important piece of information that is not explicitly stated anywhere in the docs (that I was able to find) is that a TaskToken can only be used once. After that, you will get the TaskTimedOut error, if you try to use it again.
In order to make a second callback, I had to implement a "rearming" feature in my step function and lambda. Once the first callback completes, I have a rearm step in my step function which makes another arn:aws:states:::lambda:invoke.waitForTaskToken
call, passing in a new $$.Task.Token
parameter to the lambda. The lambda can use that TaskToken at some later time to make a callback using SendTaskSuccess.
Any number of callbacks can be made, as long as this rearming process is followed.