I am attempting a step function but am not certain about the "$.<variable>" syntax. For brevity, resources like Lambda functions and S3 buckets are defined elsewhere in infraConstruct (details that I can provide upon request.)
My goal is to construct two Lambda functions. The first determines some independent tasks for execution by reading contents of an S3 bucket and applying some filtering. The output should be stored in taskArray.
The purpose of the second lambda function is to perform process to each task. Because these tasks are independent, I've selected the mapIterator in order to execute tasks in parallel.
export class StepFunctionStack extends DeploymentStack {
readonly infra;
readonly stateMachine;
readonly stepOneState;
readonly stepTwoState;
readonly sfnDefinition;
readonly mapIterator;
constructor(scope: Construct, id: string, props: StepFunctionStackProps) {
super(scope, id, props);
this.infra = new InfraConstruct(this, id, props);
this.stepOneState = new LambdaInvoke(this, 'stepOneState', {
lambdaFunction: this.infra.stepOneLambda,
resultPath: '$.taskArray',
});
this.stepTwoState = new LambdaInvoke(this, 'stepTwoState', {
lambdaFunction: this.infra.stepTwoLambda,
resultPath: '$.output',
});
this.mapIterator = new Map(this, 'Map State', {
itemsPath: '$.taskArray.Payload',
maxConcurrency: 100,
});
this.mapIterator.iterator(this.stepTwoState);
this.sfnDefinition = this.stepOneState.next(this.mapIterator);
this.stateMachine = new StateMachine(this, 'StateMachine', {
definition: this.sfnDefinition,
stateMachineName: 'StateMachine',
timeout: Duration.minutes(60),
});
}
}
The first Lambda function executes successfully! However, the error that I'm receiving in the next step is Unable to apply ReferencePath $.output to input "task_abc" Where "task_abc" is returned among the elements returned by the first Lambda function.
Note, the second Lambda function has a return type of None. Perhaps the $.output should be deleted. I assume that when None is returned, the default behavior is to return the input.
Nonetheless, why can "$.output" not be assigned a string value?
Set the
stepTwoLambdaResult Path to tonullto ignore the return value and pass the task's input value to the next task.