限制 AWS Step Functions 一次仅运行一个执行

2 locking aws-step-functions

我想在任何给定时间将步骤函数的执行次数限制为 1。有没有办法对 AWS Step 函数设置全局锁定?

Max*_*sel 5

您好,我已经通过在运行状态中显示所有 StepFunction 来解决 Step-Function 中的问题。然后它会将列表的最后一个条目与当前执行名称进行比较,如果匹配,则运行正常部分,如果偏离,则等待 30 秒并再次检查是否匹配。

阶跃函数

 {
  "StartAt": "ListExecutions",
  "States": {
    "ListExecutions": {
      "Type": "Task",
      "Parameters": {
        "StateMachineArn": "arn:aws:states:region:account-id:stateMachine:MyStateMachine",
        "StatusFilter": "RUNNING"
      },
      "Resource": "arn:aws:states:::aws-sdk:sfn:listExecutions",
      "Next": "Choice",
      "OutputPath": "$.Executions[-1:]"
    },
    "Choice": {
      "Type": "Choice",
      "Choices": [
        {
          "And": [
            {
              "Variable": "$[0].Name",
              "StringEqualsPath": "$$.Execution.Name"
            }
          ],
          "Next": "dummy processing"
        }
      ],
      "Default": "waiting for completion"
    },
    "dummy processing": {
      "Type": "Wait",
      "Seconds": 15,
      "End": true
    },
    "waiting for completion": {
      "Type": "Wait",
      "Seconds": 30,
      "Next": "ListExecutions"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)