首页 > 解决方案 > SSM 自动化运行命令不超过默认 3600 秒

问题描述

我一直在使用 AWS Systems Manager,并且创建了一个文档来运行命令,但似乎无法覆盖 SSM 中运行命令的超时

我已经在参数中更改了执行超时但不起作用。 在此处输入图像描述

另外,我在我的文档中添加了 timeoutSeconds ,它也不起作用。

这是我的文档(我使用的是架构版本 2.2):

schemaVersion: "2.2"
description: "Runs a Python command"
parameters:
  Params:
    type: "String"
    description: "Params after the python3 keyword."
mainSteps:
- action: "aws:runShellScript"
  name: "Python3"
  inputs:
    timeoutSeconds: '300000'
    runCommand:
      - "sudo /usr/bin/python3 /opt/python/current/app/{{Params}}"

标签: amazon-web-servicesdevopsaws-systems-manager

解决方案


1:屏幕截图中其他参数部分显示的设置是Delivery Timeout,它与执行超时不同。

如果可用,您必须在执行超时字段中指定执行超时值。并非所有 SSM 文档都要求您指定执行超时。如果 Systems Manager 文档不要求您明确指定执行超时值,则 Systems Manager 会强制执行硬编码的默认执行超时。

2:在您的文档中,该timeoutSeconds属性位于错误的位置。它需要与action.

...
mainSteps:
- action: "aws:runShellScript"
  timeoutSeconds: 300000
  name: "Python3"
  inputs:
    runCommand:
    - "sudo /usr/bin/python3 /opt/python/current/app/{{Params}}"

推荐阅读