question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Increase max timeout of SSM command

See original GitHub issue

In the following code, the executionTimeout parameter has a maximum value of 172800 (48 hours); I am working at a company using AWS and boto3 and it would be very useful for us to be able to run SSM commands with higher timeout lengths than 48 hours – we are looking to be able to run SSM commands which take a few days to complete. Is there any way this maximum timeout value could be increased?

boto3.Session(aws_access_key_id=aws_access_key_id,
              aws_secret_access_key=aws_secret_access_key).client('ssm'
        , region_name='us-east-1'
        ).send_command(Parameters={'commands': [command],
                       'executionTimeout': [str(timeout_sec)]}, ...)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
swetashrecommented, Aug 21, 2020

@mureytasroc - Thank you for your post. What type of SSM document are you using ? If it is AWS-RunShellScript of AWS-RunPowerShellScript you can create a custom document and change that value.

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ssm.html#SSM.Client.create_document

{
  "schemaVersion": "1.2",
  "description": "Run a shell script or specify the commands to run.",
  "parameters": {
    "commands": {
      "type": "StringList",
      "description": "(Required) Specify a shell script or a command to run.",
      "minItems": 1,
      "displayType": "textarea"
    },
    "workingDirectory": {
      "type": "String",
      "default": "",
      "description": "(Optional) The path to the working directory on your instance.",
      "maxChars": 4096
    },
    "executionTimeout": {
      "type": "String",
      "default": "3600",
      "description": "(Optional) The time in seconds for a command to complete before it is considered to have failed. Default is 3600 (1 hour). Maximum is 172800 (48 hours).",
      "allowedPattern": "([1-9][0-9]{0,4})|(1[0-6][0-9]{4})|(17[0-1][0-9]{3})|(172[0-7][0-9]{2})|(172800)"
    }
  },
  "runtimeConfig": {
    "aws:runShellScript": {
      "properties": [
        {
          "id": "0.aws:runShellScript",
          "runCommand": "{{ commands }}",
          "workingDirectory": "{{ workingDirectory }}",
          "timeoutSeconds": "{{ executionTimeout }}"
        }
      ]
    }
  }
}

Here you can change the allowedPattern: "([1-9][0-9]{0,4})|(1[0-6][0-9]{4})|(17[0-1][0-9]{3})|(172[0-7][0-9]{2})|(172800)" to allowedPattern": "([1-9][0-9]{0,4})|(1[0-6][0-9]{4})|(17[0-1][0-9]{3})|(172[0-7][0-9]{2})|(345600)" something like that.

Then with the new document, the validation rule will be 345600 instead of 172800. If that is not enough, just update the document and increase the validation rule. As long as it is less than 30 days it will be good.

0reactions
MariosTsatsoscommented, Dec 6, 2022

@mureytasroc - Thank you for your post. What type of SSM document are you using ? If it is AWS-RunShellScript of AWS-RunPowerShellScript you can create a custom document and change that value.

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ssm.html#SSM.Client.create_document

{
  "schemaVersion": "1.2",
  "description": "Run a shell script or specify the commands to run.",
  "parameters": {
    "commands": {
      "type": "StringList",
      "description": "(Required) Specify a shell script or a command to run.",
      "minItems": 1,
      "displayType": "textarea"
    },
    "workingDirectory": {
      "type": "String",
      "default": "",
      "description": "(Optional) The path to the working directory on your instance.",
      "maxChars": 4096
    },
    "executionTimeout": {
      "type": "String",
      "default": "3600",
      "description": "(Optional) The time in seconds for a command to complete before it is considered to have failed. Default is 3600 (1 hour). Maximum is 172800 (48 hours).",
      "allowedPattern": "([1-9][0-9]{0,4})|(1[0-6][0-9]{4})|(17[0-1][0-9]{3})|(172[0-7][0-9]{2})|(172800)"
    }
  },
  "runtimeConfig": {
    "aws:runShellScript": {
      "properties": [
        {
          "id": "0.aws:runShellScript",
          "runCommand": "{{ commands }}",
          "workingDirectory": "{{ workingDirectory }}",
          "timeoutSeconds": "{{ executionTimeout }}"
        }
      ]
    }
  }
}

Here you can change the allowedPattern: "([1-9][0-9]{0,4})|(1[0-6][0-9]{4})|(17[0-1][0-9]{3})|(172[0-7][0-9]{2})|(172800)" to allowedPattern": "([1-9][0-9]{0,4})|(1[0-6][0-9]{4})|(17[0-1][0-9]{3})|(172[0-7][0-9]{2})|(345600)" something like that.

Then with the new document, the validation rule will be 345600 instead of 172800. If that is not enough, just update the document and increase the validation rule. As long as it is less than 30 days it will be good.

How can I do the same from the command line? Is there a way to submit this re-configuration (allowedPattern: "…) from cli together with the run command? Or can I store it on my EC2 instance bash config somehow? Thanks!

@mureytasroc - Thank you for your post. What type of SSM document are you using ? If it is AWS-RunShellScript of AWS-RunPowerShellScript you can create a custom document and change that value.

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ssm.html#SSM.Client.create_document

{
  "schemaVersion": "1.2",
  "description": "Run a shell script or specify the commands to run.",
  "parameters": {
    "commands": {
      "type": "StringList",
      "description": "(Required) Specify a shell script or a command to run.",
      "minItems": 1,
      "displayType": "textarea"
    },
    "workingDirectory": {
      "type": "String",
      "default": "",
      "description": "(Optional) The path to the working directory on your instance.",
      "maxChars": 4096
    },
    "executionTimeout": {
      "type": "String",
      "default": "3600",
      "description": "(Optional) The time in seconds for a command to complete before it is considered to have failed. Default is 3600 (1 hour). Maximum is 172800 (48 hours).",
      "allowedPattern": "([1-9][0-9]{0,4})|(1[0-6][0-9]{4})|(17[0-1][0-9]{3})|(172[0-7][0-9]{2})|(172800)"
    }
  },
  "runtimeConfig": {
    "aws:runShellScript": {
      "properties": [
        {
          "id": "0.aws:runShellScript",
          "runCommand": "{{ commands }}",
          "workingDirectory": "{{ workingDirectory }}",
          "timeoutSeconds": "{{ executionTimeout }}"
        }
      ]
    }
  }
}

Here you can change the allowedPattern: "([1-9][0-9]{0,4})|(1[0-6][0-9]{4})|(17[0-1][0-9]{3})|(172[0-7][0-9]{2})|(172800)" to allowedPattern": "([1-9][0-9]{0,4})|(1[0-6][0-9]{4})|(17[0-1][0-9]{3})|(172[0-7][0-9]{2})|(345600)" something like that.

Then with the new document, the validation rule will be 345600 instead of 172800. If that is not enough, just update the document and increase the validation rule. As long as it is less than 30 days it will be good.

@swetashre how can I do the same from the command line? Is there a way to submit this re-configuration (allowedPattern: "…) from cli together with the run command? Or can I store it on my EC2 instance bash config somehow? Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding command statuses - AWS Systems Manager
The default for Timeout (seconds) is 3600 seconds. The default for Execution Timeout is also 3600 seconds. Therefore, the total default timeout for...
Read more >
SSM Automation Run Command is not longer than default ...
You must specify the execution timeout value in the Execution Timeout ... Systems Manager enforces the hard-coded default execution timeout.
Read more >
SSM Automation Run Command longer than default 3600 ...
Hello,. You need to change "Execution Timeout" parameters when you use Run Command utility to override the default 3600 Second value of the...
Read more >
Understanding command statuses - Amazon Systems Manager
Run Command statusUnderstanding command timeout values ... A plugin is a code-execution block that is defined in your command's SSM document.
Read more >
AWS : Simple Systems Manager (SSM) - 2020 - BogoToBogo
For Timeout (seconds), type the number of seconds that Run Command should attempt to reach an instance before it is considered unreachable and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found