2020/05/01 - Amazon Simple Systems Manager (SSM) - 2 updated api methods
Changes Added TimeoutSeconds as part of ListCommands API response.
{'Commands': {'TimeoutSeconds': 'integer'}}
Lists the commands requested by users of the AWS account.
See also: AWS API Documentation
Request Syntax
client.list_commands( CommandId='string', InstanceId='string', MaxResults=123, NextToken='string', Filters=[ { 'key': 'InvokedAfter'|'InvokedBefore'|'Status'|'ExecutionStage'|'DocumentName', 'value': 'string' }, ] )
string
(Optional) If provided, lists only the specified command.
string
(Optional) Lists commands issued against this instance ID.
integer
(Optional) The maximum number of items to return for this call. The call also returns a token that you can specify in a subsequent call to get the next set of results.
string
(Optional) The token for the next set of items to return. (You received this token from a previous call.)
list
(Optional) One or more filters. Use a filter to return a more specific list of results.
(dict) --
Describes a command filter.
key (string) -- [REQUIRED]
The name of the filter.
value (string) -- [REQUIRED]
The filter value. Valid values for each filter key are as follows:
InvokedAfter : Specify a timestamp to limit your results. For example, specify 2018-07-07T00:00:00Z to see a list of command executions occurring July 7, 2018, and later.
InvokedBefore : Specify a timestamp to limit your results. For example, specify 2018-07-07T00:00:00Z to see a list of command executions from before July 7, 2018.
Status : Specify a valid command status to see a list of all command executions with that status. Status values you can specify include:
Pending
InProgress
Success
Cancelled
Failed
TimedOut
Cancelling
DocumentName : Specify name of the SSM document for which you want to see command execution results. For example, specify AWS-RunPatchBaseline to see command executions that used this SSM document to perform security patching operations on instances.
ExecutionStage : Specify one of the following values:
Executing : Returns a list of command executions that are currently still running.
Complete : Returns a list of command executions that have already completed.
dict
Response Syntax
{ 'Commands': [ { 'CommandId': 'string', 'DocumentName': 'string', 'DocumentVersion': 'string', 'Comment': 'string', 'ExpiresAfter': datetime(2015, 1, 1), 'Parameters': { 'string': [ 'string', ] }, 'InstanceIds': [ 'string', ], 'Targets': [ { 'Key': 'string', 'Values': [ 'string', ] }, ], 'RequestedDateTime': datetime(2015, 1, 1), 'Status': 'Pending'|'InProgress'|'Success'|'Cancelled'|'Failed'|'TimedOut'|'Cancelling', 'StatusDetails': 'string', 'OutputS3Region': 'string', 'OutputS3BucketName': 'string', 'OutputS3KeyPrefix': 'string', 'MaxConcurrency': 'string', 'MaxErrors': 'string', 'TargetCount': 123, 'CompletedCount': 123, 'ErrorCount': 123, 'DeliveryTimedOutCount': 123, 'ServiceRole': 'string', 'NotificationConfig': { 'NotificationArn': 'string', 'NotificationEvents': [ 'All'|'InProgress'|'Success'|'TimedOut'|'Cancelled'|'Failed', ], 'NotificationType': 'Command'|'Invocation' }, 'CloudWatchOutputConfig': { 'CloudWatchLogGroupName': 'string', 'CloudWatchOutputEnabled': True|False }, 'TimeoutSeconds': 123 }, ], 'NextToken': 'string' }
Response Structure
(dict) --
Commands (list) --
(Optional) The list of commands requested by the user.
(dict) --
Describes a command request.
CommandId (string) --
A unique identifier for this command.
DocumentName (string) --
The name of the document requested for execution.
DocumentVersion (string) --
The SSM document version.
Comment (string) --
User-specified information about the command, such as a brief description of what the command should do.
ExpiresAfter (datetime) --
If this time is reached and the command has not already started running, it will not run. Calculated based on the ExpiresAfter user input provided as part of the SendCommand API.
Parameters (dict) --
The parameter values to be inserted in the document when running the command.
(string) --
(list) --
(string) --
InstanceIds (list) --
The instance IDs against which this command was requested.
(string) --
Targets (list) --
An array of search criteria that targets instances using a Key,Value combination that you specify. Targets is required if you don't provide one or more instance IDs in the call.
(dict) --
An array of search criteria that targets instances using a Key,Value combination that you specify.
Supported formats include the following.
``Key=InstanceIds,Values=*instance-id-1* ,*instance-id-2* ,*instance-id-3* ``
``Key=tag:my-tag-key ,Values=*my-tag-value-1* ,*my-tag-value-2* ``
``Key=tag-key,Values=*my-tag-key-1* ,*my-tag-key-2* ``
(Maintenance window targets only) ``Key=resource-groups:Name,Values=*resource-group-name* ``
(Maintenance window targets only) ``Key=resource-groups:ResourceTypeFilters,Values=*resource-type-1* ,*resource-type-2* ``
For example:
Key=InstanceIds,Values=i-02573cafcfEXAMPLE,i-0471e04240EXAMPLE,i-07782c72faEXAMPLE
Key=tag:CostCenter,Values=CostCenter1,CostCenter2,CostCenter3
Key=tag-key,Values=Name,Instance-Type,CostCenter
(Maintenance window targets only) Key=resource-groups:Name,Values=ProductionResourceGroup This example demonstrates how to target all resources in the resource group ProductionResourceGroup in your maintenance window.
(Maintenance window targets only) ``Key=resource-groups:ResourceTypeFilters,Values=*AWS::EC2::INSTANCE* ,*AWS::EC2::VPC* `` This example demonstrates how to target only EC2 instances and VPCs in your maintenance window.
(State Manager association targets only) Key=InstanceIds,Values=* This example demonstrates how to target all managed instances in the AWS Region where the association was created.
For information about how to send commands that target instances using Key,Value parameters, see Targeting multiple instances in the AWS Systems Manager User Guide .
Key (string) --
User-defined criteria for sending commands that target instances that meet the criteria.
Values (list) --
User-defined criteria that maps to Key . For example, if you specified tag:ServerRole , you could specify value:WebServer to run a command on instances that include EC2 tags of ServerRole,WebServer .
(string) --
RequestedDateTime (datetime) --
The date and time the command was requested.
Status (string) --
The status of the command.
StatusDetails (string) --
A detailed status of the command execution. StatusDetails includes more information than Status because it includes states resulting from error and concurrency control parameters. StatusDetails can show different results than Status. For more information about these statuses, see Understanding command statuses in the AWS Systems Manager User Guide . StatusDetails can be one of the following values:
Pending: The command has not been sent to any instances.
In Progress: The command has been sent to at least one instance but has not reached a final state on all instances.
Success: The command successfully ran on all invocations. This is a terminal state.
Delivery Timed Out: The value of MaxErrors or more command invocations shows a status of Delivery Timed Out. This is a terminal state.
Execution Timed Out: The value of MaxErrors or more command invocations shows a status of Execution Timed Out. This is a terminal state.
Failed: The value of MaxErrors or more command invocations shows a status of Failed. This is a terminal state.
Incomplete: The command was attempted on all instances and one or more invocations does not have a value of Success but not enough invocations failed for the status to be Failed. This is a terminal state.
Canceled: The command was terminated before it was completed. This is a terminal state.
Rate Exceeded: The number of instances targeted by the command exceeded the account limit for pending invocations. The system has canceled the command before running it on any instance. This is a terminal state.
OutputS3Region (string) --
(Deprecated) You can no longer specify this parameter. The system ignores it. Instead, Systems Manager automatically determines the Region of the S3 bucket.
OutputS3BucketName (string) --
The S3 bucket where the responses to the command executions should be stored. This was requested when issuing the command.
OutputS3KeyPrefix (string) --
The S3 directory path inside the bucket where the responses to the command executions should be stored. This was requested when issuing the command.
MaxConcurrency (string) --
The maximum number of instances that are allowed to run the command at the same time. You can specify a number of instances, such as 10, or a percentage of instances, such as 10%. The default value is 50. For more information about how to use MaxConcurrency, see Running commands using Systems Manager Run Command in the AWS Systems Manager User Guide .
MaxErrors (string) --
The maximum number of errors allowed before the system stops sending the command to additional targets. You can specify a number of errors, such as 10, or a percentage or errors, such as 10%. The default value is 0. For more information about how to use MaxErrors, see Running commands using Systems Manager Run Command in the AWS Systems Manager User Guide .
TargetCount (integer) --
The number of targets for the command.
CompletedCount (integer) --
The number of targets for which the command invocation reached a terminal state. Terminal states include the following: Success, Failed, Execution Timed Out, Delivery Timed Out, Canceled, Terminated, or Undeliverable.
ErrorCount (integer) --
The number of targets for which the status is Failed or Execution Timed Out.
DeliveryTimedOutCount (integer) --
The number of targets for which the status is Delivery Timed Out.
ServiceRole (string) --
The IAM service role that Run Command uses to act on your behalf when sending notifications about command status changes.
NotificationConfig (dict) --
Configurations for sending notifications about command status changes.
NotificationArn (string) --
An Amazon Resource Name (ARN) for an Amazon Simple Notification Service (Amazon SNS) topic. Run Command pushes notifications about command status changes to this topic.
NotificationEvents (list) --
The different events for which you can receive notifications. These events include the following: All (events), InProgress, Success, TimedOut, Cancelled, Failed. To learn more about these events, see Monitoring Systems Manager status changes using Amazon SNS notifications in the AWS Systems Manager User Guide .
(string) --
NotificationType (string) --
Command: Receive notification when the status of a command changes. Invocation: For commands sent to multiple instances, receive notification on a per-instance basis when the status of a command changes.
CloudWatchOutputConfig (dict) --
CloudWatch Logs information where you want Systems Manager to send the command output.
CloudWatchLogGroupName (string) --
The name of the CloudWatch log group where you want to send command output. If you don't specify a group name, Systems Manager automatically creates a log group for you. The log group uses the following naming format: aws/ssm/SystemsManagerDocumentName .
CloudWatchOutputEnabled (boolean) --
Enables Systems Manager to send command output to CloudWatch Logs.
TimeoutSeconds (integer) --
The TimeoutSeconds value specified for a command.
NextToken (string) --
(Optional) The token for the next set of items to return. (You received this token from a previous call.)
{'Command': {'TimeoutSeconds': 'integer'}}
Runs commands on one or more managed instances.
See also: AWS API Documentation
Request Syntax
client.send_command( InstanceIds=[ 'string', ], Targets=[ { 'Key': 'string', 'Values': [ 'string', ] }, ], DocumentName='string', DocumentVersion='string', DocumentHash='string', DocumentHashType='Sha256'|'Sha1', TimeoutSeconds=123, Comment='string', Parameters={ 'string': [ 'string', ] }, OutputS3Region='string', OutputS3BucketName='string', OutputS3KeyPrefix='string', MaxConcurrency='string', MaxErrors='string', ServiceRoleArn='string', NotificationConfig={ 'NotificationArn': 'string', 'NotificationEvents': [ 'All'|'InProgress'|'Success'|'TimedOut'|'Cancelled'|'Failed', ], 'NotificationType': 'Command'|'Invocation' }, CloudWatchOutputConfig={ 'CloudWatchLogGroupName': 'string', 'CloudWatchOutputEnabled': True|False } )
list
The instance IDs where the command should run. You can specify a maximum of 50 IDs. If you prefer not to list individual instance IDs, you can instead send commands to a fleet of instances using the Targets parameter, which accepts EC2 tags. For more information about how to use targets, see Using targets and rate controls to send commands to a fleet in the AWS Systems Manager User Guide .
(string) --
list
(Optional) An array of search criteria that targets instances using a Key,Value combination that you specify. Targets is required if you don't provide one or more instance IDs in the call. For more information about how to use targets, see Sending commands to a fleet in the AWS Systems Manager User Guide .
(dict) --
An array of search criteria that targets instances using a Key,Value combination that you specify.
Supported formats include the following.
``Key=InstanceIds,Values=*instance-id-1* ,*instance-id-2* ,*instance-id-3* ``
``Key=tag:my-tag-key ,Values=*my-tag-value-1* ,*my-tag-value-2* ``
``Key=tag-key,Values=*my-tag-key-1* ,*my-tag-key-2* ``
(Maintenance window targets only) ``Key=resource-groups:Name,Values=*resource-group-name* ``
(Maintenance window targets only) ``Key=resource-groups:ResourceTypeFilters,Values=*resource-type-1* ,*resource-type-2* ``
For example:
Key=InstanceIds,Values=i-02573cafcfEXAMPLE,i-0471e04240EXAMPLE,i-07782c72faEXAMPLE
Key=tag:CostCenter,Values=CostCenter1,CostCenter2,CostCenter3
Key=tag-key,Values=Name,Instance-Type,CostCenter
(Maintenance window targets only) Key=resource-groups:Name,Values=ProductionResourceGroup This example demonstrates how to target all resources in the resource group ProductionResourceGroup in your maintenance window.
(Maintenance window targets only) ``Key=resource-groups:ResourceTypeFilters,Values=*AWS::EC2::INSTANCE* ,*AWS::EC2::VPC* `` This example demonstrates how to target only EC2 instances and VPCs in your maintenance window.
(State Manager association targets only) Key=InstanceIds,Values=* This example demonstrates how to target all managed instances in the AWS Region where the association was created.
For information about how to send commands that target instances using Key,Value parameters, see Targeting multiple instances in the AWS Systems Manager User Guide .
Key (string) --
User-defined criteria for sending commands that target instances that meet the criteria.
Values (list) --
User-defined criteria that maps to Key . For example, if you specified tag:ServerRole , you could specify value:WebServer to run a command on instances that include EC2 tags of ServerRole,WebServer .
(string) --
string
[REQUIRED]
Required. The name of the Systems Manager document to run. This can be a public document or a custom document.
string
The SSM document version to use in the request. You can specify $DEFAULT, $LATEST, or a specific version number. If you run commands by using the AWS CLI, then you must escape the first two options by using a backslash. If you specify a version number, then you don't need to use the backslash. For example:
--document-version "$DEFAULT"
--document-version "$LATEST"
--document-version "3"
string
The Sha256 or Sha1 hash created by the system when the document was created.
Note
Sha1 hashes have been deprecated.
string
Sha256 or Sha1.
Note
Sha1 hashes have been deprecated.
integer
If this time is reached and the command has not already started running, it will not run.
string
User-specified information about the command, such as a brief description of what the command should do.
dict
The required and optional parameters specified in the document being run.
(string) --
(list) --
(string) --
string
(Deprecated) You can no longer specify this parameter. The system ignores it. Instead, Systems Manager automatically determines the Region of the S3 bucket.
string
The name of the S3 bucket where command execution responses should be stored.
string
The directory structure within the S3 bucket where the responses should be stored.
string
(Optional) The maximum number of instances that are allowed to run the command at the same time. You can specify a number such as 10 or a percentage such as 10%. The default value is 50. For more information about how to use MaxConcurrency, see Using concurrency controls in the AWS Systems Manager User Guide .
string
The maximum number of errors allowed without the command failing. When the command fails one more time beyond the value of MaxErrors, the systems stops sending the command to additional targets. You can specify a number like 10 or a percentage like 10%. The default value is 0. For more information about how to use MaxErrors, see Using error controls in the AWS Systems Manager User Guide .
string
The ARN of the IAM service role to use to publish Amazon Simple Notification Service (Amazon SNS) notifications for Run Command commands.
dict
Configurations for sending notifications.
NotificationArn (string) --
An Amazon Resource Name (ARN) for an Amazon Simple Notification Service (Amazon SNS) topic. Run Command pushes notifications about command status changes to this topic.
NotificationEvents (list) --
The different events for which you can receive notifications. These events include the following: All (events), InProgress, Success, TimedOut, Cancelled, Failed. To learn more about these events, see Monitoring Systems Manager status changes using Amazon SNS notifications in the AWS Systems Manager User Guide .
(string) --
NotificationType (string) --
Command: Receive notification when the status of a command changes. Invocation: For commands sent to multiple instances, receive notification on a per-instance basis when the status of a command changes.
dict
Enables Systems Manager to send Run Command output to Amazon CloudWatch Logs.
CloudWatchLogGroupName (string) --
The name of the CloudWatch log group where you want to send command output. If you don't specify a group name, Systems Manager automatically creates a log group for you. The log group uses the following naming format: aws/ssm/SystemsManagerDocumentName .
CloudWatchOutputEnabled (boolean) --
Enables Systems Manager to send command output to CloudWatch Logs.
dict
Response Syntax
{ 'Command': { 'CommandId': 'string', 'DocumentName': 'string', 'DocumentVersion': 'string', 'Comment': 'string', 'ExpiresAfter': datetime(2015, 1, 1), 'Parameters': { 'string': [ 'string', ] }, 'InstanceIds': [ 'string', ], 'Targets': [ { 'Key': 'string', 'Values': [ 'string', ] }, ], 'RequestedDateTime': datetime(2015, 1, 1), 'Status': 'Pending'|'InProgress'|'Success'|'Cancelled'|'Failed'|'TimedOut'|'Cancelling', 'StatusDetails': 'string', 'OutputS3Region': 'string', 'OutputS3BucketName': 'string', 'OutputS3KeyPrefix': 'string', 'MaxConcurrency': 'string', 'MaxErrors': 'string', 'TargetCount': 123, 'CompletedCount': 123, 'ErrorCount': 123, 'DeliveryTimedOutCount': 123, 'ServiceRole': 'string', 'NotificationConfig': { 'NotificationArn': 'string', 'NotificationEvents': [ 'All'|'InProgress'|'Success'|'TimedOut'|'Cancelled'|'Failed', ], 'NotificationType': 'Command'|'Invocation' }, 'CloudWatchOutputConfig': { 'CloudWatchLogGroupName': 'string', 'CloudWatchOutputEnabled': True|False }, 'TimeoutSeconds': 123 } }
Response Structure
(dict) --
Command (dict) --
The request as it was received by Systems Manager. Also provides the command ID which can be used future references to this request.
CommandId (string) --
A unique identifier for this command.
DocumentName (string) --
The name of the document requested for execution.
DocumentVersion (string) --
The SSM document version.
Comment (string) --
User-specified information about the command, such as a brief description of what the command should do.
ExpiresAfter (datetime) --
If this time is reached and the command has not already started running, it will not run. Calculated based on the ExpiresAfter user input provided as part of the SendCommand API.
Parameters (dict) --
The parameter values to be inserted in the document when running the command.
(string) --
(list) --
(string) --
InstanceIds (list) --
The instance IDs against which this command was requested.
(string) --
Targets (list) --
An array of search criteria that targets instances using a Key,Value combination that you specify. Targets is required if you don't provide one or more instance IDs in the call.
(dict) --
An array of search criteria that targets instances using a Key,Value combination that you specify.
Supported formats include the following.
``Key=InstanceIds,Values=*instance-id-1* ,*instance-id-2* ,*instance-id-3* ``
``Key=tag:my-tag-key ,Values=*my-tag-value-1* ,*my-tag-value-2* ``
``Key=tag-key,Values=*my-tag-key-1* ,*my-tag-key-2* ``
(Maintenance window targets only) ``Key=resource-groups:Name,Values=*resource-group-name* ``
(Maintenance window targets only) ``Key=resource-groups:ResourceTypeFilters,Values=*resource-type-1* ,*resource-type-2* ``
For example:
Key=InstanceIds,Values=i-02573cafcfEXAMPLE,i-0471e04240EXAMPLE,i-07782c72faEXAMPLE
Key=tag:CostCenter,Values=CostCenter1,CostCenter2,CostCenter3
Key=tag-key,Values=Name,Instance-Type,CostCenter
(Maintenance window targets only) Key=resource-groups:Name,Values=ProductionResourceGroup This example demonstrates how to target all resources in the resource group ProductionResourceGroup in your maintenance window.
(Maintenance window targets only) ``Key=resource-groups:ResourceTypeFilters,Values=*AWS::EC2::INSTANCE* ,*AWS::EC2::VPC* `` This example demonstrates how to target only EC2 instances and VPCs in your maintenance window.
(State Manager association targets only) Key=InstanceIds,Values=* This example demonstrates how to target all managed instances in the AWS Region where the association was created.
For information about how to send commands that target instances using Key,Value parameters, see Targeting multiple instances in the AWS Systems Manager User Guide .
Key (string) --
User-defined criteria for sending commands that target instances that meet the criteria.
Values (list) --
User-defined criteria that maps to Key . For example, if you specified tag:ServerRole , you could specify value:WebServer to run a command on instances that include EC2 tags of ServerRole,WebServer .
(string) --
RequestedDateTime (datetime) --
The date and time the command was requested.
Status (string) --
The status of the command.
StatusDetails (string) --
A detailed status of the command execution. StatusDetails includes more information than Status because it includes states resulting from error and concurrency control parameters. StatusDetails can show different results than Status. For more information about these statuses, see Understanding command statuses in the AWS Systems Manager User Guide . StatusDetails can be one of the following values:
Pending: The command has not been sent to any instances.
In Progress: The command has been sent to at least one instance but has not reached a final state on all instances.
Success: The command successfully ran on all invocations. This is a terminal state.
Delivery Timed Out: The value of MaxErrors or more command invocations shows a status of Delivery Timed Out. This is a terminal state.
Execution Timed Out: The value of MaxErrors or more command invocations shows a status of Execution Timed Out. This is a terminal state.
Failed: The value of MaxErrors or more command invocations shows a status of Failed. This is a terminal state.
Incomplete: The command was attempted on all instances and one or more invocations does not have a value of Success but not enough invocations failed for the status to be Failed. This is a terminal state.
Canceled: The command was terminated before it was completed. This is a terminal state.
Rate Exceeded: The number of instances targeted by the command exceeded the account limit for pending invocations. The system has canceled the command before running it on any instance. This is a terminal state.
OutputS3Region (string) --
(Deprecated) You can no longer specify this parameter. The system ignores it. Instead, Systems Manager automatically determines the Region of the S3 bucket.
OutputS3BucketName (string) --
The S3 bucket where the responses to the command executions should be stored. This was requested when issuing the command.
OutputS3KeyPrefix (string) --
The S3 directory path inside the bucket where the responses to the command executions should be stored. This was requested when issuing the command.
MaxConcurrency (string) --
The maximum number of instances that are allowed to run the command at the same time. You can specify a number of instances, such as 10, or a percentage of instances, such as 10%. The default value is 50. For more information about how to use MaxConcurrency, see Running commands using Systems Manager Run Command in the AWS Systems Manager User Guide .
MaxErrors (string) --
The maximum number of errors allowed before the system stops sending the command to additional targets. You can specify a number of errors, such as 10, or a percentage or errors, such as 10%. The default value is 0. For more information about how to use MaxErrors, see Running commands using Systems Manager Run Command in the AWS Systems Manager User Guide .
TargetCount (integer) --
The number of targets for the command.
CompletedCount (integer) --
The number of targets for which the command invocation reached a terminal state. Terminal states include the following: Success, Failed, Execution Timed Out, Delivery Timed Out, Canceled, Terminated, or Undeliverable.
ErrorCount (integer) --
The number of targets for which the status is Failed or Execution Timed Out.
DeliveryTimedOutCount (integer) --
The number of targets for which the status is Delivery Timed Out.
ServiceRole (string) --
The IAM service role that Run Command uses to act on your behalf when sending notifications about command status changes.
NotificationConfig (dict) --
Configurations for sending notifications about command status changes.
NotificationArn (string) --
An Amazon Resource Name (ARN) for an Amazon Simple Notification Service (Amazon SNS) topic. Run Command pushes notifications about command status changes to this topic.
NotificationEvents (list) --
The different events for which you can receive notifications. These events include the following: All (events), InProgress, Success, TimedOut, Cancelled, Failed. To learn more about these events, see Monitoring Systems Manager status changes using Amazon SNS notifications in the AWS Systems Manager User Guide .
(string) --
NotificationType (string) --
Command: Receive notification when the status of a command changes. Invocation: For commands sent to multiple instances, receive notification on a per-instance basis when the status of a command changes.
CloudWatchOutputConfig (dict) --
CloudWatch Logs information where you want Systems Manager to send the command output.
CloudWatchLogGroupName (string) --
The name of the CloudWatch log group where you want to send command output. If you don't specify a group name, Systems Manager automatically creates a log group for you. The log group uses the following naming format: aws/ssm/SystemsManagerDocumentName .
CloudWatchOutputEnabled (boolean) --
Enables Systems Manager to send command output to CloudWatch Logs.
TimeoutSeconds (integer) --
The TimeoutSeconds value specified for a command.