-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws-stepfunctions-tasks: Confusion between RunLambdaTask and InvokeFunction #4801
Comments
I'm open to ideas for good verbiage to put in the class descriptions. |
Or the README |
…mbda (#6796) The InvokeFunction Step Functions task is being marked as deprecated. It represents the legacy way to represent Lambda functions in Step Functions The RunLambda task represents the recommended way to invoke Lambdas in Step Functions. see: https://docs.aws.amazon.com/step-functions/latest/dg/connect-lambda.html Examples in the README have been updated to use RunLambdaTask Closes #4801
Since I am getting obsolete warning on InvokeFunction(this has been working fine for us), we moved to RunLambdaTask. Since then we have been receiving null ref exception in the lambda function. Seems like the payload passed to lambda function is null? Any thoughts? @rix0rrr @otterley The code with InvokeFunction looked like this: var postToApiTask = new Task(scope, $"{props.UniqueFunctionSuffix}-PostAPI-Task", new TaskProps
{
Task = new InvokeFunction(props.PostToAPILambda), //this is the lambda function
InputPath = "$",
ResultPath = "$.data.lambdaResult",
Comment = "This task invokes API endpoint",
Timeout = Duration.Seconds(30)
}); I just replace InvokeFunction with RunLambdaTask. I tried setting some properties as well, but no luck. |
@sacag can you share the code that you were using when you converted to Did you set the IntegrationPattern property? Wondering if it's the default of In TypeScript it would look something like this: task: new tasks.RunLambdaTask(postToAPILambda, {
integrationPattern: sfn.ServiceIntegrationPattern.WAIT_FOR_TASK_TOKEN,
payload: {
token: sfn.Context.taskToken
}
}),
inputPath: '$',
resultPath: '$.lambdaResult',
comment: 'This task invokes API endpoint',
timeout: Duration.seconds(30)
}); |
@shivlaks - I did not set the IntegrationPattern property. Also, my lambda function is not accepting/returning any token or anything of that sort. Below is how my C# code looks like: In the above code I just replaced InvokeFunction with RunLambdaTask and it stopped working Are you suggesting I shall try with the props you are setting in your typescript code and see? without any changes to the lambda function? |
@shivlaks - I tried Context.EntireContext, Context.TaskToken..still same issue var applyFilterTransformTask = new Task(scope, $"{props.UniqueFunctionSuffix}-FilterTransform-Task", new TaskProps
{
Task = new RunLambdaTask(props.FilterTransformLambda,
new RunLambdaTaskProps { IntegrationPattern = ServiceIntegrationPattern.WAIT_FOR_TASK_TOKEN,
Payload = new Dictionary<string, object>() { { "input",Context.EntireContext} } }),
Comment = $"This task applies source/destination filters to {props.UserFriendlyTopicName} Message and also Transforms it",
InputPath = "$",
ResultPath = "$.data.lambdaResult",
OutputPath = "$.data.lambdaResult",
Timeout = Duration.Seconds(15),
}); |
@shivlaks - finally got it to work with the below code: |
@shivlaks, @rix0rrr - I am seeing more issues with RunLambdaTask:
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
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? |
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 useRunLambdaTask
.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.
The text was updated successfully, but these errors were encountered: