You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何设置AWS SSM send-command取消executionTime默认3600秒超时限制

解决方案

你无法直接在send_command的顶层参数中配置ExecutionTimeout的核心原因是:该参数不属于API的顶层请求参数,而是SSM Document定义的业务执行参数,需要放在请求的Parameters字段中传递。

场景1:使用AWS托管公共SSM Document(如AWS-RunShellScript、AWS-RunPowerShellScript)

这类公共Document已经预先定义了executionTimeout参数,直接在Parameters字段中传入即可,示例代码如下:

import boto3

ssm = boto3.client('ssm')

resp = ssm.send_command(
    InstanceIds=['i-替换为你的实例ID'],
    DocumentName='AWS-RunShellScript',
    # 顶层参数:控制send_command API请求本身的超时时间
    TimeoutSeconds=60,
    Parameters={
        'commands': ['你的命令内容'],
        # 执行超时参数,单位为秒,必须放在Parameters下,值用列表包裹
        'executionTimeout': ['7200']
    }
)

场景2:使用自定义SSM Document

你需要先在自定义Document的schema中声明executionTimeout参数,并且将参数绑定到执行步骤的超时配置上,示例Document schema(YAML格式)如下:

schemaVersion: "2.2"
description: "自定义执行脚本文档"
parameters:
  # 先声明executionTimeout参数
  executionTimeout:
    type: "String"
    default: "3600"
    description: "命令在实例上执行的最大超时时间,单位秒"
  customCommands:
    type: "StringList"
    description: "要执行的自定义命令列表"
mainSteps:
  - action: "aws:runShellScript"
    name: "executeCustomCommands"
    inputs:
      runCommand: "{{ customCommands }}"
      # 将步骤的超时时间绑定到你声明的executionTimeout参数
      timeoutSeconds: "{{ executionTimeout }}"

更新自定义Document之后,就可以和公共Document一样,在send_command的Parameters字段中传入自定义的executionTimeout值。

控制台配置的原理说明

AWS控制台会自动读取你选择的SSM Document的所有可配置参数,将包括executionTimeout在内的所有参数渲染为可视化配置项,你在控制台填写的执行超时值,最终会被控制台自动放到API请求的Parameters字段中提交,和上述代码的传参逻辑完全一致。

内容的提问来源于stack exchange,提问作者sye

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.12 01:15:03