Amazon Simple Systems Manager (SSM)

2018/06/13 - Amazon Simple Systems Manager (SSM) - 4 updated api methods

Changes  Added support for new parameter, CloudWatchOutputConfig, for SendCommand API. Users can now have RunCommand output sent to CloudWatchLogs.

GetCommandInvocation (updated) Link ¶
Changes (response)
{'CloudWatchOutputConfig': {'CloudWatchLogGroupName': 'string',
                            'CloudWatchOutputEnabled': 'boolean'}}

Returns detailed information about command execution for an invocation or plugin.

See also: AWS API Documentation

Request Syntax

client.get_command_invocation(
    CommandId='string',
    InstanceId='string',
    PluginName='string'
)
type CommandId

string

param CommandId

[REQUIRED]

(Required) The parent command ID of the invocation plugin.

type InstanceId

string

param InstanceId

[REQUIRED]

(Required) The ID of the managed instance targeted by the command. A managed instance can be an Amazon EC2 instance or an instance in your hybrid environment that is configured for Systems Manager.

type PluginName

string

param PluginName

(Optional) The name of the plugin for which you want detailed results. If the document contains only one plugin, the name can be omitted and the details will be returned.

rtype

dict

returns

Response Syntax

{
    'CommandId': 'string',
    'InstanceId': 'string',
    'Comment': 'string',
    'DocumentName': 'string',
    'DocumentVersion': 'string',
    'PluginName': 'string',
    'ResponseCode': 123,
    'ExecutionStartDateTime': 'string',
    'ExecutionElapsedTime': 'string',
    'ExecutionEndDateTime': 'string',
    'Status': 'Pending'|'InProgress'|'Delayed'|'Success'|'Cancelled'|'TimedOut'|'Failed'|'Cancelling',
    'StatusDetails': 'string',
    'StandardOutputContent': 'string',
    'StandardOutputUrl': 'string',
    'StandardErrorContent': 'string',
    'StandardErrorUrl': 'string',
    'CloudWatchOutputConfig': {
        'CloudWatchLogGroupName': 'string',
        'CloudWatchOutputEnabled': True|False
    }
}

Response Structure

  • (dict) --

    • CommandId (string) --

      The parent command ID of the invocation plugin.

    • InstanceId (string) --

      The ID of the managed instance targeted by the command. A managed instance can be an Amazon EC2 instance or an instance in your hybrid environment that is configured for Systems Manager.

    • Comment (string) --

      The comment text for the command.

    • DocumentName (string) --

      The name of the document that was executed. For example, AWS-RunShellScript.

    • DocumentVersion (string) --

      The SSM document version used in the request.

    • PluginName (string) --

      The name of the plugin for which you want detailed results. For example, aws:RunShellScript is a plugin.

    • ResponseCode (integer) --

      The error level response code for the plugin script. If the response code is -1, then the command has not started executing on the instance, or it was not received by the instance.

    • ExecutionStartDateTime (string) --

      The date and time the plugin started executing. Date and time are written in ISO 8601 format. For example, June 7, 2017 is represented as 2017-06-7. The following sample AWS CLI command uses the InvokedBefore filter.

      aws ssm list-commands --filters key=InvokedBefore,value=2017-06-07T00:00:00Z

      If the plugin has not started to execute, the string is empty.

    • ExecutionElapsedTime (string) --

      Duration since ExecutionStartDateTime.

    • ExecutionEndDateTime (string) --

      The date and time the plugin was finished executing. Date and time are written in ISO 8601 format. For example, June 7, 2017 is represented as 2017-06-7. The following sample AWS CLI command uses the InvokedAfter filter.

      aws ssm list-commands --filters key=InvokedAfter,value=2017-06-07T00:00:00Z

      If the plugin has not started to execute, the string is empty.

    • Status (string) --

      The status of this invocation plugin. This status can be different than StatusDetails.

    • StatusDetails (string) --

      A detailed status of the command execution for an invocation. 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 the instance.

      • In Progress: The command has been sent to the instance but has not reached a terminal state.

      • Delayed: The system attempted to send the command to the target, but the target was not available. The instance might not be available because of network issues, the instance was stopped, etc. The system will try to deliver the command again.

      • Success: The command or plugin was executed successfully. This is a terminal state.

      • Delivery Timed Out: The command was not delivered to the instance before the delivery timeout expired. Delivery timeouts do not count against the parent command's MaxErrors limit, but they do contribute to whether the parent command status is Success or Incomplete. This is a terminal state.

      • Execution Timed Out: The command started to execute on the instance, but the execution was not complete before the timeout expired. Execution timeouts count against the MaxErrors limit of the parent command. This is a terminal state.

      • Failed: The command wasn't executed successfully on the instance. For a plugin, this indicates that the result code was not zero. For a command invocation, this indicates that the result code for one or more plugins was not zero. Invocation failures count against the MaxErrors limit of the parent command. This is a terminal state.

      • Canceled: The command was terminated before it was completed. This is a terminal state.

      • Undeliverable: The command can't be delivered to the instance. The instance might not exist or might not be responding. Undeliverable invocations don't count against the parent command's MaxErrors limit and don't contribute to whether the parent command status is Success or Incomplete. This is a terminal state.

      • Terminated: The parent command exceeded its MaxErrors limit and subsequent command invocations were canceled by the system. This is a terminal state.

    • StandardOutputContent (string) --

      The first 24,000 characters written by the plugin to stdout. If the command has not finished executing, if ExecutionStatus is neither Succeeded nor Failed, then this string is empty.

    • StandardOutputUrl (string) --

      The URL for the complete text written by the plugin to stdout in Amazon S3. If an Amazon S3 bucket was not specified, then this string is empty.

    • StandardErrorContent (string) --

      The first 8,000 characters written by the plugin to stderr. If the command has not finished executing, then this string is empty.

    • StandardErrorUrl (string) --

      The URL for the complete text written by the plugin to stderr. If the command has not finished executing, then this string is empty.

    • CloudWatchOutputConfig (dict) --

      CloudWatch Logs information where Systems Manager sent 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.

ListCommandInvocations (updated) Link ¶
Changes (response)
{'CommandInvocations': {'CloudWatchOutputConfig': {'CloudWatchLogGroupName': 'string',
                                                   'CloudWatchOutputEnabled': 'boolean'}}}

An invocation is copy of a command sent to a specific instance. A command can apply to one or more instances. A command invocation applies to one instance. For example, if a user executes SendCommand against three instances, then a command invocation is created for each requested instance ID. ListCommandInvocations provide status about command execution.

See also: AWS API Documentation

Request Syntax

client.list_command_invocations(
    CommandId='string',
    InstanceId='string',
    MaxResults=123,
    NextToken='string',
    Filters=[
        {
            'key': 'InvokedAfter'|'InvokedBefore'|'Status',
            'value': 'string'
        },
    ],
    Details=True|False
)
type CommandId

string

param CommandId

(Optional) The invocations for a specific command ID.

type InstanceId

string

param InstanceId

(Optional) The command execution details for a specific instance ID.

type MaxResults

integer

param MaxResults

(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.

type NextToken

string

param NextToken

(Optional) The token for the next set of items to return. (You received this token from a previous call.)

type Filters

list

param Filters

(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.

type Details

boolean

param Details

(Optional) If set this returns the response of the command executions and any command output. By default this is set to False.

rtype

dict

returns

Response Syntax

{
    'CommandInvocations': [
        {
            'CommandId': 'string',
            'InstanceId': 'string',
            'InstanceName': 'string',
            'Comment': 'string',
            'DocumentName': 'string',
            'DocumentVersion': 'string',
            'RequestedDateTime': datetime(2015, 1, 1),
            'Status': 'Pending'|'InProgress'|'Delayed'|'Success'|'Cancelled'|'TimedOut'|'Failed'|'Cancelling',
            'StatusDetails': 'string',
            'TraceOutput': 'string',
            'StandardOutputUrl': 'string',
            'StandardErrorUrl': 'string',
            'CommandPlugins': [
                {
                    'Name': 'string',
                    'Status': 'Pending'|'InProgress'|'Success'|'TimedOut'|'Cancelled'|'Failed',
                    'StatusDetails': 'string',
                    'ResponseCode': 123,
                    'ResponseStartDateTime': datetime(2015, 1, 1),
                    'ResponseFinishDateTime': datetime(2015, 1, 1),
                    'Output': 'string',
                    'StandardOutputUrl': 'string',
                    'StandardErrorUrl': 'string',
                    'OutputS3Region': 'string',
                    'OutputS3BucketName': 'string',
                    'OutputS3KeyPrefix': 'string'
                },
            ],
            'ServiceRole': 'string',
            'NotificationConfig': {
                'NotificationArn': 'string',
                'NotificationEvents': [
                    'All'|'InProgress'|'Success'|'TimedOut'|'Cancelled'|'Failed',
                ],
                'NotificationType': 'Command'|'Invocation'
            },
            'CloudWatchOutputConfig': {
                'CloudWatchLogGroupName': 'string',
                'CloudWatchOutputEnabled': True|False
            }
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • CommandInvocations (list) --

      (Optional) A list of all invocations.

      • (dict) --

        An invocation is copy of a command sent to a specific instance. A command can apply to one or more instances. A command invocation applies to one instance. For example, if a user executes SendCommand against three instances, then a command invocation is created for each requested instance ID. A command invocation returns status and detail information about a command you executed.

        • CommandId (string) --

          The command against which this invocation was requested.

        • InstanceId (string) --

          The instance ID in which this invocation was requested.

        • InstanceName (string) --

          The name of the invocation target. For Amazon EC2 instances this is the value for the aws:Name tag. For on-premises instances, this is the name of the instance.

        • Comment (string) --

          User-specified information about the command, such as a brief description of what the command should do.

        • DocumentName (string) --

          The document name that was requested for execution.

        • DocumentVersion (string) --

          The SSM document version.

        • RequestedDateTime (datetime) --

          The time and date the request was sent to this instance.

        • Status (string) --

          Whether or not the invocation succeeded, failed, or is pending.

        • StatusDetails (string) --

          A detailed status of the command execution for each invocation (each instance targeted by the command). 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 the instance.

          • In Progress: The command has been sent to the instance but has not reached a terminal state.

          • Success: The execution of the command or plugin was successfully completed. This is a terminal state.

          • Delivery Timed Out: The command was not delivered to the instance before the delivery timeout expired. Delivery timeouts do not count against the parent command's MaxErrors limit, but they do contribute to whether the parent command status is Success or Incomplete. This is a terminal state.

          • Execution Timed Out: Command execution started on the instance, but the execution was not complete before the execution timeout expired. Execution timeouts count against the MaxErrors limit of the parent command. This is a terminal state.

          • Failed: The command was not successful on the instance. For a plugin, this indicates that the result code was not zero. For a command invocation, this indicates that the result code for one or more plugins was not zero. Invocation failures count against the MaxErrors limit of the parent command. This is a terminal state.

          • Canceled: The command was terminated before it was completed. This is a terminal state.

          • Undeliverable: The command can't be delivered to the instance. The instance might not exist or might not be responding. Undeliverable invocations don't count against the parent command's MaxErrors limit and don't contribute to whether the parent command status is Success or Incomplete. This is a terminal state.

          • Terminated: The parent command exceeded its MaxErrors limit and subsequent command invocations were canceled by the system. This is a terminal state.

        • TraceOutput (string) --

          Gets the trace output sent by the agent.

        • StandardOutputUrl (string) --

          The URL to the plugin's StdOut file in Amazon S3, if the Amazon S3 bucket was defined for the parent command. For an invocation, StandardOutputUrl is populated if there is just one plugin defined for the command, and the Amazon S3 bucket was defined for the command.

        • StandardErrorUrl (string) --

          The URL to the plugin's StdErr file in Amazon S3, if the Amazon S3 bucket was defined for the parent command. For an invocation, StandardErrorUrl is populated if there is just one plugin defined for the command, and the Amazon S3 bucket was defined for the command.

        • CommandPlugins (list) --

          • (dict) --

            Describes plugin details.

            • Name (string) --

              The name of the plugin. Must be one of the following: aws:updateAgent, aws:domainjoin, aws:applications, aws:runPowerShellScript, aws:psmodule, aws:cloudWatch, aws:runShellScript, or aws:updateSSMAgent.

            • Status (string) --

              The status of this plugin. You can execute a document with multiple plugins.

            • StatusDetails (string) --

              A detailed status of the plugin 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 the instance.

              • In Progress: The command has been sent to the instance but has not reached a terminal state.

              • Success: The execution of the command or plugin was successfully completed. This is a terminal state.

              • Delivery Timed Out: The command was not delivered to the instance before the delivery timeout expired. Delivery timeouts do not count against the parent command's MaxErrors limit, but they do contribute to whether the parent command status is Success or Incomplete. This is a terminal state.

              • Execution Timed Out: Command execution started on the instance, but the execution was not complete before the execution timeout expired. Execution timeouts count against the MaxErrors limit of the parent command. This is a terminal state.

              • Failed: The command was not successful on the instance. For a plugin, this indicates that the result code was not zero. For a command invocation, this indicates that the result code for one or more plugins was not zero. Invocation failures count against the MaxErrors limit of the parent command. This is a terminal state.

              • Canceled: The command was terminated before it was completed. This is a terminal state.

              • Undeliverable: The command can't be delivered to the instance. The instance might not exist, or it might not be responding. Undeliverable invocations don't count against the parent command's MaxErrors limit, and they don't contribute to whether the parent command status is Success or Incomplete. This is a terminal state.

              • Terminated: The parent command exceeded its MaxErrors limit and subsequent command invocations were canceled by the system. This is a terminal state.

            • ResponseCode (integer) --

              A numeric response code generated after executing the plugin.

            • ResponseStartDateTime (datetime) --

              The time the plugin started executing.

            • ResponseFinishDateTime (datetime) --

              The time the plugin stopped executing. Could stop prematurely if, for example, a cancel command was sent.

            • Output (string) --

              Output of the plugin execution.

            • StandardOutputUrl (string) --

              The URL for the complete text written by the plugin to stdout in Amazon S3. If the Amazon S3 bucket for the command was not specified, then this string is empty.

            • StandardErrorUrl (string) --

              The URL for the complete text written by the plugin to stderr. If execution is not yet complete, then this string is empty.

            • OutputS3Region (string) --

              (Deprecated) You can no longer specify this parameter. The system ignores it. Instead, Systems Manager automatically determines the Amazon S3 bucket region.

            • OutputS3BucketName (string) --

              The S3 bucket where the responses to the command executions should be stored. This was requested when issuing the command. For example, in the following response:

              test_folder/ab19cb99-a030-46dd-9dfc-8eSAMPLEPre-Fix/i-1234567876543/awsrunShellScript

              test_folder is the name of the Amazon S3 bucket;

              ab19cb99-a030-46dd-9dfc-8eSAMPLEPre-Fix is the name of the S3 prefix;

              i-1234567876543 is the instance ID;

              awsrunShellScript is the name of the plugin.

            • 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. For example, in the following response:

              test_folder/ab19cb99-a030-46dd-9dfc-8eSAMPLEPre-Fix/i-1234567876543/awsrunShellScript

              test_folder is the name of the Amazon S3 bucket;

              ab19cb99-a030-46dd-9dfc-8eSAMPLEPre-Fix is the name of the S3 prefix;

              i-1234567876543 is the instance ID;

              awsrunShellScript is the name of the plugin.

        • ServiceRole (string) --

          The IAM service role that Run Command uses to act on your behalf when sending notifications about command status changes on a per instance basis.

        • NotificationConfig (dict) --

          Configurations for sending notifications about command status changes on a per instance basis.

          • NotificationArn (string) --

            An Amazon Resource Name (ARN) for a Simple Notification Service (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 Configuring Amazon SNS Notifications for Run Command 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.

    • NextToken (string) --

      (Optional) The token for the next set of items to return. (You received this token from a previous call.)

ListCommands (updated) Link ¶
Changes (response)
{'Commands': {'CloudWatchOutputConfig': {'CloudWatchLogGroupName': 'string',
                                         'CloudWatchOutputEnabled': 'boolean'},
              'DeliveryTimedOutCount': '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',
            'value': 'string'
        },
    ]
)
type CommandId

string

param CommandId

(Optional) If provided, lists only the specified command.

type InstanceId

string

param InstanceId

(Optional) Lists commands issued against this instance ID.

type MaxResults

integer

param MaxResults

(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.

type NextToken

string

param NextToken

(Optional) The token for the next set of items to return. (You received this token from a previous call.)

type Filters

list

param Filters

(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.

rtype

dict

returns

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
            }
        },
    ],
    '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 executing, 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 executing 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. Targets is required if you don't provide one or more instance IDs in the call.

            • Key (string) --

              User-defined criteria for sending commands that target instances that meet the criteria. Key can be tag:<Amazon EC2 tag> or InstanceIds. For more information about how to send commands that target instances using Key,Value parameters, see Targeting Multiple Instances in the AWS Systems Manager User Guide .

            • Values (list) --

              User-defined criteria that maps to Key. For example, if you specified tag:ServerRole, you could specify value:WebServer to execute a command on instances that include Amazon EC2 tags of ServerRole,WebServer. For more information about how to send commands that target instances using Key,Value parameters, see Sending Commands to a Fleet in the AWS Systems Manager User Guide .

              • (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 executed 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 executing 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 Amazon S3 bucket region.

        • 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 execute 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 Executing 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 Executing 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 a Simple Notification Service (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 Configuring Amazon SNS Notifications for Run Command 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.

    • NextToken (string) --

      (Optional) The token for the next set of items to return. (You received this token from a previous call.)

SendCommand (updated) Link ¶
Changes (request, response)
Request
{'CloudWatchOutputConfig': {'CloudWatchLogGroupName': 'string',
                            'CloudWatchOutputEnabled': 'boolean'}}
Response
{'Command': {'CloudWatchOutputConfig': {'CloudWatchLogGroupName': 'string',
                                        'CloudWatchOutputEnabled': 'boolean'},
             'DeliveryTimedOutCount': 'integer'}}

Executes 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
    }
)
type InstanceIds

list

param InstanceIds

The instance IDs where the command should execute. 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 Sending Commands to a Fleet in the AWS Systems Manager User Guide .

  • (string) --

type Targets

list

param Targets

(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. Targets is required if you don't provide one or more instance IDs in the call.

    • Key (string) --

      User-defined criteria for sending commands that target instances that meet the criteria. Key can be tag:<Amazon EC2 tag> or InstanceIds. For more information about how to send commands that target instances using Key,Value parameters, see Targeting Multiple Instances in the AWS Systems Manager User Guide .

    • Values (list) --

      User-defined criteria that maps to Key. For example, if you specified tag:ServerRole, you could specify value:WebServer to execute a command on instances that include Amazon EC2 tags of ServerRole,WebServer. For more information about how to send commands that target instances using Key,Value parameters, see Sending Commands to a Fleet in the AWS Systems Manager User Guide .

      • (string) --

type DocumentName

string

param DocumentName

[REQUIRED]

Required. The name of the Systems Manager document to execute. This can be a public document or a custom document.

type DocumentVersion

string

param DocumentVersion

The SSM document version to use in the request. You can specify $DEFAULT, $LATEST, or a specific version number. If you execute 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"

type DocumentHash

string

param DocumentHash

The Sha256 or Sha1 hash created by the system when the document was created.

Note

Sha1 hashes have been deprecated.

type DocumentHashType

string

param DocumentHashType

Sha256 or Sha1.

Note

Sha1 hashes have been deprecated.

type TimeoutSeconds

integer

param TimeoutSeconds

If this time is reached and the command has not already started executing, it will not run.

type Comment

string

param Comment

User-specified information about the command, such as a brief description of what the command should do.

type Parameters

dict

param Parameters

The required and optional parameters specified in the document being executed.

  • (string) --

    • (list) --

      • (string) --

type OutputS3Region

string

param OutputS3Region

(Deprecated) You can no longer specify this parameter. The system ignores it. Instead, Systems Manager automatically determines the Amazon S3 bucket region.

type OutputS3BucketName

string

param OutputS3BucketName

The name of the S3 bucket where command execution responses should be stored.

type OutputS3KeyPrefix

string

param OutputS3KeyPrefix

The directory structure within the S3 bucket where the responses should be stored.

type MaxConcurrency

string

param MaxConcurrency

(Optional) The maximum number of instances that are allowed to execute 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 .

type MaxErrors

string

param MaxErrors

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 .

type ServiceRoleArn

string

param ServiceRoleArn

The IAM role that Systems Manager uses to send notifications.

type NotificationConfig

dict

param NotificationConfig

Configurations for sending notifications.

  • NotificationArn (string) --

    An Amazon Resource Name (ARN) for a Simple Notification Service (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 Configuring Amazon SNS Notifications for Run Command 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.

type CloudWatchOutputConfig

dict

param CloudWatchOutputConfig

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.

rtype

dict

returns

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
        }
    }
}

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 executing, 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 executing 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. Targets is required if you don't provide one or more instance IDs in the call.

          • Key (string) --

            User-defined criteria for sending commands that target instances that meet the criteria. Key can be tag:<Amazon EC2 tag> or InstanceIds. For more information about how to send commands that target instances using Key,Value parameters, see Targeting Multiple Instances in the AWS Systems Manager User Guide .

          • Values (list) --

            User-defined criteria that maps to Key. For example, if you specified tag:ServerRole, you could specify value:WebServer to execute a command on instances that include Amazon EC2 tags of ServerRole,WebServer. For more information about how to send commands that target instances using Key,Value parameters, see Sending Commands to a Fleet in the AWS Systems Manager User Guide .

            • (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 executed 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 executing 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 Amazon S3 bucket region.

      • 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 execute 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 Executing 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 Executing 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 a Simple Notification Service (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 Configuring Amazon SNS Notifications for Run Command 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.