以下是step函数,它在每个步骤中触发不同的lambda函数。步进功能从“ first_step”开始。
{
"Comment": "Step function",
"StartAt": "first_step",
"States": {
"first_step": {
"Type": "Task",
"Resource": "lambda_function1",
"Next": "second_step"
},
"second_step": {
"Type": "Task",
"Resource": "lambda_function2",
"Next": "third_step"
},
"third_step": {
"Type": "Task",
"Resource": "lambda_function3",
"End" : true
}
}
}
现在,我想通过Lambda函数从特定步骤(second_step)调用step函数。 也就是说,一旦我触发另一个Lambda函数(lambda_function4),step函数就应该从second_step(跳过first_step)开始执行,并继续执行到最后。
此外,我正在使用Python创建Lambda函数。
答案 0 :(得分:1)
您将需要在函数的开头添加一个Choice步骤,以确定接下来要转到的lambda并传入一个参数以进行区分。由于您无法调用步骤功能,因此可以选择要从
开始的步骤因此它看起来像:
{
"Comment": "Step function",
"StartAt": "flowDirector",
"States": {
"flowDirector": {
"Type" : "Choice",
"Choices": [
{
"Variable": "$.customVarName",
"StringEquals": "Cancel",
"Next": "first_step"
},
{
"Variable": "$.customVarName",
"StringEquals": "CameFromFunction4",
"Next": "second_step"
}
],
"Default": "first_step"
},
"first_step": {
"Type": "Task",
"Resource": "lambda_function1",
"Next": "second_step"
},
"second_step": {
"Type": "Task",
"Resource": "lambda_function2",
"Next": "third_step"
},
"third_step": {
"Type": "Task",
"Resource": "lambda_function3",
"End" : true
}
}
}
然后更新您的python代码,以将额外的参数发送到step函数中,以便它可以计算从哪里开始。
response = client.start_execution(
stateMachineArn='string',
name='string',
input='"{\"customVarName\" : \"CameFromFunction4\"}"'
)