question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[aws-stepfunctions-tasks] Unable to use the Wait for task Token: Task Token is missing in payload (pass Context.taskToken somewhere in payload)

See original GitHub issue

❓ How to specify the task token + pass input on the payload with the RunLambdaTask

The Question

How can I specify a task that uses the wait for task token using CDK.

The README does not contain an example using the RunLambdaTask (https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/aws-stepfunctions-tasks#lambda) so I took the existing one and adapted like below

const reserveHotel = new sfn.Task(this, 'doX', {
      task: new tasks.RunLambdaTask(doXLambda, {
        integrationPattern: sfn.ServiceIntegrationPattern.WAIT_FOR_TASK_TOKEN,
        payload: sfn.TaskInput.fromObject({
          taskToken: "$$.Task.Token",
          input: "$"
        })
      }),
      resultPath: '$.Result'
    }).addCatch(otherTask, {
      resultPath: "$.Error"
    });

When trying to use cdk synth it complains “Task Token is missing in payload (pass Context.taskToken somewhere in payload)”. I’ve tried variations using the sfn.Context.taskToken but same result.

I guess it would be beneficial to update the ReadME to indicate the correct way of doing so.

Environment

  • CDK CLI Version: 1.54.0 (build c01b9b9)
  • Module Version: Not sure
  • Node.js Version: 12.18.3
  • OS: Ubuntu 20
  • Language (Version): Typescript

Other information

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mariobittencourtcommented, Jul 31, 2020
payload: sfn.TaskInput.fromObject({
          token: sfn.JsonPath.taskToken,
          input: sfn.JsonPath.entirePayload
        })

Did the trick. I hope it is the right way.

0reactions
shivlakscommented, Jul 31, 2020

@mariobittencourt great!

I should also mention the default should be the entire payload if you’re using LambdaInvoke. you shouldn’t need to explicitly specify it unless you’re selecting part of the state input.

Read more comments on GitHub >

github_iconTop Results From Across the Web

aws cdk - Aws StepFunction path with waitForTaskToken
I think you want to pass resultPath to props instead of payload . const publishIot = new tasks. ... taskToken, request: sfn.JsonPath.
Read more >
aws-cdk/aws-stepfunctions-tasks module
When passing the Task Token in the headers field WAIT_FOR_TASK_TOKEN integration, use JsonPath.array() to wrap the token in an array: import * as...
Read more >
Handling Step Function Task Tokens failures with CDK
This post shows you how to handle failures with Step Functions Task Tokens in AWS CDK.
Read more >
Combine AWS Step Functions with CloudWatch Events using ...
aws-cdk; Step Function; Lambda. The example demonstrates how Step Functions manage execution of a process, which involves external events e.g. ...
Read more >
aws-cdk.aws-stepfunctions
entirePayload, reference the entire data object (equivalent to a path of $ ). JsonPath.taskToken, reference the Task Token, used for integration patterns ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found