boto3: SSM command times out before given executionTimeout seconds have elapsed
When I run the following code to run an SSM command on another instance, the command stops after 1 hour rather than 2505600 seconds = 29 days (although no InvalidParameter errors are thrown when I start the command):
ssm_client.send_command(
InstanceIds=[instance_id],
DocumentName="RunShellScript-LongRunning",
Parameters={
"commands": [command],
"executionTimeout": ["2505600"],
}
)
where RunShellScript-LongRunning is the name of my created SSM document (of the same form as AWS-RunShellScript except with anything up to 2505600 allowed for executionTimeout instead of 172800 being the max; "allowedPattern": "([1-9][0-9]{0,5})|(1[0-9]{6})|(2[0-4][0-9]{5})|(250[0-4][0-9]{3})|(2505[0-5][0-9]{2})|(2505600)"):
{
"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 2505600 (29 days).",
"allowedPattern": "([1-9][0-9]{0,5})|(1[0-9]{6})|(2[0-4][0-9]{5})|(250[0-4][0-9]{3})|(2505[0-5][0-9]{2})|(2505600)"
}
},
"runtimeConfig": {
"aws:runShellScript": {
"properties": [
{
"id": "0.aws:runShellScript",
"runCommand": "{{ commands }}",
"workingDirectory": "{{ workingDirectory }}",
"timeoutSeconds": "{{ executionTimeout }}"
}
]
}
}
}
When I pass an executionTimeout parameter of “172800” to send_command, it does not stop after 1 hour and continues running normally. When I use the same document but pass an executionTimeout parameter of “172801” to send_command, it does stop after 1 hour. It seems that there is some bug in the SSM that implicitly rejects an executionTimeout of above 172800 seconds = 48 hours by instead timing out execution after the default of 1 hour, even if it is not rejected explicitly by the allowedPattern in the SSM document (which would throw an InvalidParameter error).
Do you have any idea about how to fix this?
In this original guidance thread, I was advised to use SSM documents to increase the max executionTimeout of commands initiated by send_command, but this seems to be an actual bug.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (7 by maintainers)
Hello @markjayne, I’m looking into this.