In one of my step, I am using a lambda function as a task and I want to pass the entire input as the payload
so that it can convert to a strong type Java object I defined.
My data type as Object:
@Data
public class JobMetaData {
public JobMetaData() {
}
private String jobName;
private String jobId;
Lambda Function:
@Override
public JobMetaData handleRequest(final JobMetaData jobMetaData,
final Context context) {
Step:
"Preparing Job": {
"Next": "Submitting Job",
"InputPath": "$",
"OutputPath": "$.bakeJobResult",
"Type": "Task",
"Comment": "Preparing Job",
"Parameters": {
"FunctionName": "MyLambdaFunctionName",
"Payload": {
"$": "$"
}
},
"Resource": "arn:aws:states:::lambda:invoke",
"ResultPath": "$.bakeJobResult"
}
Above step will result in JobMetaData
passed in as null
.
I can only get it work by changing it to:
"Payload": {
"jobName.$": "$.jobName",
"jobId.$": "$.jobId"
}
But if I have a lot of fields, this means I need to extract all json field and construct them again to make it a Payload. I am using CDK to define my state machine, it looks like the Payload
part is defined as a Map<String, Object>
. Is there a way I can just pass the entire input as payload?