ListCommands - AWS Systems Manager

ListCommands

Lists the commands requested by users of the AWS account.

Request Syntax

{ "CommandId": "string", "Filters": [ { "key": "string", "value": "string" } ], "InstanceId": "string", "MaxResults": number, "NextToken": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

CommandId

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

Type: String

Length Constraints: Fixed length of 36.

Required: No

Filters

(Optional) One or more filters. Use a filter to return a more specific list of results.

Type: Array of CommandFilter objects

Array Members: Minimum number of 1 item. Maximum number of 5 items.

Required: No

InstanceId

(Optional) Lists commands issued against this managed node ID.

Note

You can't specify a managed node ID in the same command that you specify Status = Pending. This is because the command hasn't reached the managed node yet.

Type: String

Pattern: (^i-(\w{8}|\w{17})$)|(^mi-\w{17}$)

Required: No

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: Integer

Valid Range: Minimum value of 1. Maximum value of 50.

Required: No

NextToken

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

Type: String

Required: No

Response Syntax

{ "Commands": [ { "AlarmConfiguration": { "Alarms": [ { "Name": "string" } ], "IgnorePollAlarmFailure": boolean }, "CloudWatchOutputConfig": { "CloudWatchLogGroupName": "string", "CloudWatchOutputEnabled": boolean }, "CommandId": "string", "Comment": "string", "CompletedCount": number, "DeliveryTimedOutCount": number, "DocumentName": "string", "DocumentVersion": "string", "ErrorCount": number, "ExpiresAfter": number, "InstanceIds": [ "string" ], "MaxConcurrency": "string", "MaxErrors": "string", "NotificationConfig": { "NotificationArn": "string", "NotificationEvents": [ "string" ], "NotificationType": "string" }, "OutputS3BucketName": "string", "OutputS3KeyPrefix": "string", "OutputS3Region": "string", "Parameters": { "string" : [ "string" ] }, "RequestedDateTime": number, "ServiceRole": "string", "Status": "string", "StatusDetails": "string", "TargetCount": number, "Targets": [ { "Key": "string", "Values": [ "string" ] } ], "TimeoutSeconds": number, "TriggeredAlarms": [ { "Name": "string", "State": "string" } ] } ], "NextToken": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

Commands

(Optional) The list of commands requested by the user.

Type: Array of Command objects

NextToken

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

Type: String

Errors

For information about the errors that are common to all actions, see Common Errors.

InternalServerError

An error occurred on the server side.

HTTP Status Code: 500

InvalidCommandId

The specified command ID isn't valid. Verify the ID and try again.

HTTP Status Code: 400

InvalidFilterKey

The specified key isn't valid.

HTTP Status Code: 400

InvalidInstanceId

The following problems can cause this exception:

  • You don't have permission to access the managed node.

  • AWS Systems Manager Agent (SSM Agent) isn't running. Verify that SSM Agent is running.

  • SSM Agent isn't registered with the SSM endpoint. Try reinstalling SSM Agent.

  • The managed node isn't in a valid state. Valid states are: Running, Pending, Stopped, and Stopping. Invalid states are: Shutting-down and Terminated.

HTTP Status Code: 400

InvalidNextToken

The specified token isn't valid.

HTTP Status Code: 400

Examples

Example

This example illustrates one usage of ListCommands.

Sample Request

POST / HTTP/1.1 Host: ssm.us-east-2.amazonaws.com Accept-Encoding: identity X-Amz-Target: AmazonSSM.ListCommands Content-Type: application/x-amz-json-1.1 User-Agent: aws-cli/2.0.0 Python/3.7.5 Windows/10 botocore/2.0.0dev4 X-Amz-Date: 20200221T002657Z Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20200221/us-east-2/ssm/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=39c3b3042cd2aEXAMPLE Content-Length: 53 { "CommandId": "088e4813-f292-48b3-8180-d8be9EXAMPLE" }

Sample Response

{ "Commands": [ { "CloudWatchOutputConfig": { "CloudWatchLogGroupName": "my-log-group", "CloudWatchOutputEnabled": true }, "CommandId": "088e4813-f292-48b3-8180-d8be9EXAMPLE", "Comment": "", "CompletedCount": 0, "DeliveryTimedOutCount": 0, "DocumentName": "AWS-InstallMissingWindowsUpdates", "DocumentVersion": "1", "ErrorCount": 0, "ExpiresAfter": 1582248743.188, "InstanceIds": [], "Interactive": false, "MaxConcurrency": "2", "MaxErrors": "3", "NotificationConfig": { "NotificationArn": "arn:aws:sns:us-east-2:111122223333:my-us-east-2-notification-arn", "NotificationEvents": [ "All" ], "NotificationType": "Command" }, "OutputS3BucketName": "doc-example-bucket", "OutputS3KeyPrefix": "my-rc-output", "Parameters": { "ExcludeKbArticleIds": [ "" ], "UpdateLevel": [ "All" ] }, "RequestedDateTime": 1582244543.188, "ServiceRole": "arn:aws:iam::111122223333:role/my-SNS-notifications-role", "Status": "InProgress", "StatusDetails": "InProgress", "TargetCount": 5, "Targets": [ { "Key": "InstanceIds", "Values": [ "i-09c350ed76EXAMPLE", "i-07be1baa4aEXAMPLE", "i-00ec29b21eEXAMPLE", "i-09911ddd90EXAMPLE", "i-017431b35cEXAMPLE" ] } ] } ] }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: