0

I have a lambda that produces an array of json objects. I want the lambda result passed to a step function under a given attribute name.

Input to task that runs lambda:

{
"foo": "abc",
"bar": "def"
}

Output I want

{
"foo": "abc",
"bar": "def",
"lambdaOutput": [
  {...},
  {...}
]
}

I thought ResultSelector + ResultPath is supposed to solve this problem but I am stuck. I tried

"ResultSelector": {
        "lambdaOutput.$": "$.Payload",
      },
      "ResultPath": "$.lambdaOutput"

But this just creates a nested structure

{
"foo": "abc",
"bar": "def",
"lambdaOutput": 
    "lambdaOutput: {
    [ 
      {...},
      {...}
    ]
    }
}

What am i missing?

2 Answers 2

1

Not sure how to do it from console, but from CDK, you can specify payloadResponseOnly

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

Sign up to request clarification or add additional context in comments.

Comments

0

Disclaimer: I'm not an Amazon States Language expert, but try just:

{
  ResultPath: "$.lambdaOutput"
}

1 Comment

That just inserts the payload inside of lambdaOutput. Anyway I found out that in CDK there is an option called payloadResponseOnly that solves this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.