Darkin Rall
Darkin Rall

Reputation: 459

How get taskToken step function?

I have sfn with activity. I want to get taskToken in lambda, which execute SendTaskSuccess. Multiple sfn start execute. I need to get taskToken for sfn specific execution in oreder to continue it.Method getActivityTask returns GetActivityTaskResult starting from oldest sfn execution to newest. It doesn't suit me, if it returned a list of running execution, but no. How can I get needed taskToken for me?

Upvotes: 0

Views: 3935

Answers (1)

aws-jordan
aws-jordan

Reputation: 110

Thanks for your question and for your interest in Step Functions.

The task token for a Task state can be accessed from the global Context Object, and passed to the invoked Lambda function as part of its payload.

Here's what the state definition would look like in the waitForTask token task state example:

{  
   "StartAt":"GetManualReview",
   "States":{  
      "GetManualReview":{  
         "Type":"Task",
         "Resource":"arn:aws:states:::lambda:invoke.waitForTaskToken",
         "Parameters":{  
            "FunctionName":"get-model-review-decision",
            "Payload":{  
               "model.$":"$.new_model",
               "token.$":"$$.Task.Token"
            },
            "Qualifier":"prod-v1"
         },
         "End":true
      }
   }
}

See: Invoke Lambda with Step Functions - AWS Step Functions

Upvotes: 3

Related Questions