问题描述
我的 AWS lambda 函数 check-version-lambda
返回
{"latest": "yes"}
或 {"latest": "no"}
。
我有下面的 AWS 步骤函数,可以将上面的结果传递给下一个状态。
下一个状态 process_version
是一个选择状态,我如何检索 Choices
中的输入? <???>
需要填写什么?
{
"StartAt": "check_version","States": {
"check_version": {
"Type": "Task","Resource": "arn:aws:lambda:us-east-1:000:function:check-version-lambda","OutputPath": "$.latest","Next": "process_version"
},"process_version": {
"Type": "Choice","Choices": [
{
"Variable": "<???>","StringEquals": "yes","Next": "next_state"
},{
"Variable": "<???>","StringEquals": "no","Next": "next_state"
}
],"Default": "next_state"
}
}
}
解决方法
在您的“check_version”状态下,您可以使用
"ResultPath": "$.result","OutputPath": "$.result",
显式配置 step 函数以将 lambda 的结果(例如 {"latest": "yes"}
)放入输入对象的 result
属性中。 OutputPath
告诉 step 函数只选择该结果作为状态输出并将其移交给下一个状态。
在您的“process_version”状态下,您应该可以使用:
"Variable": "$.result.latest","StringEquals": "yes","Next": ...
来源:https://docs.aws.amazon.com/step-functions/latest/dg/input-output-example.html