I would like to dynamically chose an AWS Lambda worker based on the result coming from a previous step. Something like {"Resource": "$.worker_arn"}
.
"RunWorkers": {
"Type": "Map",
"MaxConcurrency": 0,
"InputPath": "$.output",
"ResultPath": "$.raw_result",
"Iterator": {
"StartAt": "CallWorkerLambda",
"States": {
"CallWorkerLambda": {
"Type": "Task",
"Resource": "$$.worker_arn",
"End": true
}
}
},
"Next": "Aggregate"
},
The input from previous step is expected as following:
[{"worker_arn":..., "output":1}, {"worker_arn":..., "output":1}, ...]
,
where worker_arn
is the same among all workers.
When I write a pipeline like this, the linter complains that it expects an ARN.
Are there any options better than wrapping my worker lambda into another lambda?
Using "Resource": "arm:aws:states:::lambda:invoke"
you can set the "FunctionName"
field in "Parameters"
at runtime using a Path.
{
"StartAt":"CallLambda",
"States":{
"CallLambda":{
"Type":"Task",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters":{
"FunctionName.$":"$.MyFunction",
"Payload.$": "$"
},
"End":true
}
}
}
https://docs.aws.amazon.com/step-functions/latest/dg/connect-lambda.html