如何获取具有状态机名称的statemachineARN



我有一个状态机名称(例如:custom-state-machine),而我想要这个的statemachineARN,我怎么才能实现呢?

有一个函数,listrongtate_machines(),但是它给出了所有状态机的详细信息。此外,我还看到了函数describe_state_machine(),但它需要statemachineARN。

我的目标是从状态机

的名称中获取statemachineARN

这是一种方法。使用listrongtate_machine调用获取所有步骤函数的列表,然后遍历每个函数,如果名称上有匹配,则提取ARN。

import boto3
name = 'HelloWorld'
sfn_arn = None
client = boto3.client('stepfunctions')
response = client.list_state_machines()['stateMachines']
for sfn in response:
if sfn['name'] == name:
sfn_arn = sfn['stateMachineArn']

最新更新