AWS状态机的执行状态可以通过AWS Lambda来查询。以下是Python代码示例:
import boto3
client = boto3.client('stepfunctions')
def lambda_handler(event, context):
execution_arn = 'ARN_OF_THE_EXECUTION'
execution_status = client.describe_execution(executionArn=execution_arn)['status']
print('Execution status is:', execution_status)
return {
'statusCode': 200,
'body': json.dumps('Execution status is: ' + execution_status)
}
此代码示例使用Boto3库与AWS SDK进行交互。首先,需要将ARN_OF_THE_EXECUTION替换为您的状态机执行ARN。然后,使用describe_execution方法查询执行状态。最后,结果将在控制台输出,并作为response body返回。