AWS 阶跃函数:动态选择资源
AWS step function: chosing a Resource dynamically
我想根据上一步的结果动态选择一个 AWS Lambda worker。类似于 {"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"
},
上一步的输入预计如下:
[{"worker_arn":..., "output":1}, {"worker_arn":..., "output":1}, ...]
,
其中 worker_arn
在所有工人中都相同。
当我编写这样的管道时,linter 抱怨它需要一个 ARN。
有没有比将我的工作程序 lambda 包装到另一个 lambda 更好的选择?
使用 "Resource": "arm:aws:states:::lambda:invoke"
,您可以在运行时使用路径在 "Parameters"
中设置 "FunctionName"
字段。
{
"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
我想根据上一步的结果动态选择一个 AWS Lambda worker。类似于 {"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"
},
上一步的输入预计如下:
[{"worker_arn":..., "output":1}, {"worker_arn":..., "output":1}, ...]
,
其中 worker_arn
在所有工人中都相同。
当我编写这样的管道时,linter 抱怨它需要一个 ARN。
有没有比将我的工作程序 lambda 包装到另一个 lambda 更好的选择?
使用 "Resource": "arm:aws:states:::lambda:invoke"
,您可以在运行时使用路径在 "Parameters"
中设置 "FunctionName"
字段。
{
"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