用途
awsclaw-stepfunc 是 awsclaw VS Code 扩展中的 StepFuncTool 语言工具,用于在 VS Code 中管理 AWS Step Functions 的状态机、执行和活动,并处理相关生命周期操作。
主要能力
StepFuncTool 共提供 28 个命令:
- 描述类:DescribeActivity、DescribeExecution、DescribeMapRun、DescribeStateMachine、DescribeStateMachineAlias、DescribeStateMachineForExecution
- 历史与列表类:GetExecutionHistory、ListActivities、ListExecutions、ListMapRuns、ListStateMachineAliases、ListStateMachines、ListStateMachineVersions
- 执行与更新类:StartExecution、UpdateStateMachine、ValidateStateMachineDefinition
- 创建类:CreateStateMachine、CreateActivity、CreateStateMachineAlias、PublishStateMachineVersion
- 标签类:TagResource、UntagResource
- 删除类:DeleteStateMachine、DeleteActivity、DeleteStateMachineAlias、DeleteStateMachineVersion
- 停止与别名更新类:StopExecution、UpdateStateMachineAlias
使用方式
工具名称为 StepFuncTool,输入 Schema 为:
{ "command": "<CommandName>", "params": { ... } }
常用参数包括:stateMachineArn(字符串,DescribeStateMachine、StartExecution、UpdateStateMachine 必需,ListExecutions 使用)、executionArn(字符串,DescribeExecution、GetExecutionHistory 必需)、maxResults(数字)、nextToken(字符串)、reverseOrder(布尔值)、statusFilter(字符串,枚举 RUNNING、SUCCEEDED、FAILED、TIMED_OUT、ABORTED)、name(字符串,StartExecution 使用)、input(字符串,StartExecution 使用)、traceHeader(字符串,StartExecution 使用)、definition(字符串,UpdateStateMachine 使用)、roleArn(字符串,UpdateStateMachine 使用)、loggingConfiguration(对象,UpdateStateMachine 使用)、tracingConfiguration(对象,UpdateStateMachine 使用)、publish(布尔值,UpdateStateMachine 使用)、versionDescription(字符串,UpdateStateMachine 使用)。
调用示例(来自资料):
列出全部状态机:
{ "command": "ListStateMachines", "params": { "maxResults": 20 } }
描述状态机:
{ "command": "DescribeStateMachine", "params": { "stateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:MyWorkflow" } }
按状态过滤列出执行:
{ "command": "ListExecutions", "params": { "stateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:MyWorkflow", "statusFilter": "FAILED", "maxResults": 10 } }
启动新执行:
{ "command": "StartExecution", "params": { "stateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:MyWorkflow", "input": "{\"orderId\": \"12345\", \"amount\": 99.99}" } }
获取执行历史:
{ "command": "GetExecutionHistory", "params": { "executionArn": "arn:aws:states:us-east-1:123456789012:execution:MyWorkflow:exec-id", "maxResults": 100, "reverseOrder": true } }
描述执行:
{ "command": "DescribeExecution", "params": { "executionArn": "arn:aws:states:us-east-1:123456789012:execution:MyWorkflow:exec-id" } }
更新状态机定义:
{ "command": "UpdateStateMachine", "params": { "stateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:MyWorkflow", "definition": "{\"StartAt\": \"Step1\", \"States\": { \"Step1\": { \"Type\": \"Pass\", \"End\": true }}}" } }
校验定义:
{ "command": "ValidateStateMachineDefinition", "params": {} }
创建状态机:
{ "command": "CreateStateMachine", "params": { "name": "MyWorkflow", "definition": "{\"StartAt\":\"Step1\",\"States\":{\"Step1\":{\"Type\":\"Pass\",\"End\":true}}}", "roleArn": "arn:aws:iam::123456789012:role/StepFuncRole" } }
停止执行:
{ "command": "StopExecution", "params": { "executionArn": "arn:aws:states:...:execution:MyWorkflow:exec-id", "cause": "manual stop" } }
适用场景
- 用户希望列出或描述状态机
- 用户希望启动新执行或查看已有执行
- 用户希望查看执行历史(逐步事件)
- 用户希望更新状态机定义
- 用户希望校验状态机定义
- 用户希望列出或描述活动与 Map Run
- 用户希望创建或删除状态机与活动
- 用户希望停止执行或管理标签与别名
相关服务
Step Functions 可跨多个 AWS 服务编排工作流。资料列出的关系包括:调用 Lambda 函数(LambdaTool)、向 SQS 发送消息(SQSTool)、发布到 SNS 主题(SNSTool)、读写 DynamoDB 表(DynamoDBTool)、启动 Glue 作业(GlueTool)、启动 EMR 步骤(EMRTool)、调用 API Gateway 端点(APIGatewayTool)、在 CloudWatch 中记录执行日志(CloudWatchLogTool)、执行所用 IAM 角色(IAMTool)、通过 CloudFormation 部署(CloudFormationTool)。
Step Functions 日志组通常遵循命名:
/aws/vendedlogs/states/<state-machine-name>-Logs
可使用 CloudWatchLogTool → DescribeLogGroups,配合 logGroupNamePrefix: "/aws/vendedlogs/states/" 查找。
使用提示
- 使用 ListStateMachines → DescribeStateMachine 浏览定义与配置。
- 使用 ListExecutions 并设置 statusFilter: "FAILED" 查找失败运行,再用 GetExecutionHistory 逐步调试。
- StartExecution 需要 stateMachineArn,并接受 JSON 输入字符串。
- UpdateStateMachine 中的 definition 必须是有效的 Amazon States Language JSON。
- 在 GetExecutionHistory 中使用 reverseOrder: true 可优先看到最近的事件。
限制
资料未提供该工具的计费、价格、平台支持范围、性能指标及使用配额等信息,暂未提供。