Home > Back-end >  How to add optional variable in Step Function in typescript
How to add optional variable in Step Function in typescript

Time:05-04

In the following code, if documentDetails is available in payload of the step function for step Read, then only documentDetails variable be considered, otherwise it shouldn't be. documentDetails is optional and it may or may not be there in payload.

const readStep = new tasks.LambdaInvoke(this, 'Read', {
            lambdaFunction: stepfLambda,
            resultSelector: {
                "s3Url.$": "$.Payload.s3Url",
                "documentDetails.$": // present only if documentDetails is present in Payload
            },
            resultPath: '$.stepEventMetaData'
        });

What is the correct syntax for the same?

CodePudding user response:

resultSelector cannot apply conditional logic. Your best option is to have stepfLambda return the output in the desired shape.

  • Related