aws / aws/aws-cdk

(aws_stepfunctions_tasks): Unclear how LambdaInvoke works

Open
#29,473 7 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-stepfunctions-tasks documentation feature-request p3
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the issue

My Lambda function returns JSON data

It's unclear what the return value of the step is though - is it just the JSON that the Lambda itself returns, or is it an "invoke lambda response" JSON? Or something else?

I'm using/attempting to use the Step Functions local testing tool
https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-mock-cfg-file.html#mock-cfg-mckd-resp-sect:~:text=to%20the%20next.-,Return,-Return%20is%20represented

in the docs there they show example mocked response for a LambdaInvoke step as:
```json
{
"StatusCode": 200,
"Payload": {
"StatusCode": 200,
"body": "Hello from Lambda!"
}
}
```

This implies I may need to post-process the output of the lambda step with something like `States.StringToJson($.Payload.body)`?

There is a `payloadResponseOnly` option for the `LambdaInvoke` construct but again it's not clear what it does.

The docs say:

> Invoke the Lambda in a way that only returns the payload response without additional metadata.

...which is super vague. Does it return `$.Payload.body`? Does it parse it as JSON too? Something else?

Whatever it does I am unable to test this option in the local mock tool because it causes it to need a Lambda arn rather than just the Lambda name(?)... I get errors like _"CreateStateMachine <= Invalid State Machine Definition: ''SCHEMA_VALIDATION_FAILED: Value is not a valid resource ARN at /States/Process Batch Unit/Branches[0]/States/Invoke-ProcessBatchLambda/Resource"_ (...since there is no easy way to derive the ASL json from the CDK code I am having to use this other tool [`cdk-asl-extractor`](https://github.com/nathanagez/aws-cdk-state-machine-asl) to reconstruct it from CF template, but there is no real ARN for the Lambda when testing locally)

### Links

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions_tasks.LambdaInvoke.html#payload

Contributor guide

Open the contributing guide

Research direction

Start with the LambdaInvoke payload documentation and the AWS Step Functions Local mock response example linked in the issue. Verify the actual output with and without payloadResponseOnly, including whether the payload is parsed and how local mocking handles the resource ARN. Done means documenting the resulting JSON shapes and a workable local-test setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
cloud, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.