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: Confusion between RunLambdaTask and InvokeFunction

See original GitHub issue

There are now two similar-looking constructs in aws-stepfunctions-tasks pertaining to Lambda tasks, and it’s not clear which one to use.

Users who are used to historical Step Functions patterns and want things to easily work should use InvokeFunction. However, there are some corner cases where people want special behavior (e.g., asynchronous execution) who like to use RunLambdaTask.

If you mix these up, be prepared to spend a lot of time debugging. @ccfife and I spent the afternoon scratching our heads to figure out, when we accidentally used RunLambdaTask, why the event payload being sent to our Lambda function Tasks was an empty event.

Let’s do something to disambiguate these and make clear when a user should use one or the other.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
sacagcommented, Apr 14, 2020

@shivlaks - finally got it to work with the below code: new RunLambdaTask(props.PostToAPILambda,new RunLambdaTaskProps { Payload = new Dictionary<string, object>() { { "input", Context.StringAt("$$.Execution.Input") } } })

0reactions
sacagcommented, Apr 15, 2020

@shivlaks, @rix0rrr - I am seeing more issues with RunLambdaTask: below is the code which works with InvokeFunction…$.Payload has my model in json string

 Task = new InvokeFunction(lambdaFunction),                
                InputPath = "$.Payload",
                ResultPath = "$.lambdaResult",
                OutputPath = "$.lambdaResult"

The same code when using RunLambdaTask…not sure how to access $.Payload in the Payload property, so that it can be passed over to the Lambda function? This is what I have. This passes NULL to my lambda function

Task = new RunLambdaTask(lambdaFunction,
                            new RunLambdaTaskProps 
{ Payload = new Dictionary<string, object>() { { "lambdaResult", Context.StringAt("$$.Payload") } } }),
                InputPath = "$.Payload",
                ResultPath = "$.lambdaResult",
                OutputPath = "$.lambdaResult"

When I do Context.StringAt(…) in RunLambdaTask, i think it takes the execution’s input and not the task input…i think, maybe there is another way to access the TaskState input?
@otterley - wondering if you were able to figure this out?

Read more comments on GitHub >

github_iconTop Results From Across the Web

class RunLambdaTask · AWS CDK
Invoke a Lambda function as a Task. OUTPUT: the output of this task is either the return value of Lambda's Invoke call, or...
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