如何停止特定状态机的所有正在运行的步进功能? [英] How to stop all running Step Functions of a specific state machine?

查看:71
本文介绍了如何停止特定状态机的所有正在运行的步进功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不小心启动了很多步进功能,现在希望终止所有这些功能.

I accidentally started very many step functions and now wish to terminate all of them.

使用CLI或Web控制台执行此操作的任何聪明方法吗?

Any smart ways to do this using the CLI or web console?

推荐答案

好的,让我们使用CLI来完成此操作.

OK, let's do this using the CLI.

您可以使用以下命令停止执行:

You can stop an execution using the following:

aws stepfunctions stop-execution \
  --execution-arn <STEP FUNCTION EXECUTION ARN>

但是由于我开始执行的方式太多,因此能够列出状态机的所有正在运行的执行方式将很有帮助:

But since I started way too many executions, it's helpful to be able to list all running executions of a state machine:

aws stepfunctions list-executions \
  --state-machine-arn <STEP FUNCTION ARN> \
  --status-filter RUNNING \
  --output text

接下来,确保仅列出这些执行的执行ARN,并在单独的行上列出每个执行ARN:

Next, make sure to only list execution ARN's for these executions and list each execution ARN on a separate line:

aws stepfunctions list-executions \
  --state-machine-arn <STEP FUNCTION ARN> \
  --status-filter RUNNING \
  --query "executions[*].{executionArn:executionArn}" \
  --output text

现在,我们使用 xargs 将它们放到一个命令中:

Now, we put this together into one command using xargs:

aws stepfunctions list-executions \
  --state-machine-arn <STEP FUNCTION ARN> \
  --status-filter RUNNING \
  --query "executions[*].{executionArn:executionArn}" \
  --output text | \
xargs -I {} aws stepfunctions stop-execution \
  --execution-arn {} 

现在应关闭所有正在运行的执行程序.确保谨慎执行此操作,以免影响生产!

Now all running executions should be shut down. Make sure you do this with care so that you don't mess up production!

请注意,如果您使用aws-vault来最大程度地降低这种风险,则上面的命令将如下所示:

On that note, if you user aws-vault to minimize that very risk, the command above would look something like this:

aws-vault exec test-env -- aws stepfunctions list-executions \
  --state-machine-arn <STEP FUNCTION ARN> \
  --status-filter RUNNING \
  --query "executions[*].{executionArn:executionArn}" \
  --output text | \
xargs -I {} aws-vault exec test-env -- aws stepfunctions stop-execution \
  --execution-arn {} 

这篇关于如何停止特定状态机的所有正在运行的步进功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆