ListCommandInvocations - AWS Systems Manager

ListCommandInvocations

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

Request Syntax

{ "CommandId": "string", "Details": boolean, "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) The invocations for a specific command ID.

Type: String

Length Constraints: Fixed length of 36.

Required: No

Details

(Optional) If set this returns the response of the command executions and any command output. The default value is false.

Type: Boolean

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) The command execution details for a specific managed node ID.

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

{ "CommandInvocations": [ { "CloudWatchOutputConfig": { "CloudWatchLogGroupName": "string", "CloudWatchOutputEnabled": boolean }, "CommandId": "string", "CommandPlugins": [ { "Name": "string", "Output": "string", "OutputS3BucketName": "string", "OutputS3KeyPrefix": "string", "OutputS3Region": "string", "ResponseCode": number, "ResponseFinishDateTime": number, "ResponseStartDateTime": number, "StandardErrorUrl": "string", "StandardOutputUrl": "string", "Status": "string", "StatusDetails": "string" } ], "Comment": "string", "DocumentName": "string", "DocumentVersion": "string", "InstanceId": "string", "InstanceName": "string", "NotificationConfig": { "NotificationArn": "string", "NotificationEvents": [ "string" ], "NotificationType": "string" }, "RequestedDateTime": number, "ServiceRole": "string", "StandardErrorUrl": "string", "StandardOutputUrl": "string", "Status": "string", "StatusDetails": "string", "TraceOutput": "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.

CommandInvocations

(Optional) A list of all invocations.

Type: Array of CommandInvocation 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 ListCommandInvocations.

Sample Request

POST / HTTP/1.1 Host: ssm.us-east-2.amazonaws.com Accept-Encoding: identity X-Amz-Target: AmazonSSM.ListCommandInvocations 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: 20240221T000322Z Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20240221/us-east-2/ssm/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=39c3b3042cd2aEXAMPLE Content-Length: 53 { "CommandId": "4171bb3b-fe26-48ea-94fe-d1727b4d58e5" }

Sample Response

{ "CommandInvocations": [ { "CloudWatchOutputConfig": { "CloudWatchLogGroupName": "", "CloudWatchOutputEnabled": false }, "CommandId": "4171bb3b-fe26-48ea-94fe-d1727EXAMPLE", "CommandPlugins": [], "Comment": "", "DocumentName": "AWS-FindWindowsUpdates", "DocumentVersion": "1", "InstanceId": "i-02573cafcfEXAMPLE", "InstanceName": "EXAMPLE-4J5FVEG.WORKGROUP", "NotificationConfig": { "NotificationArn": "arn:aws:sns:us-east-2:111122223333:my-us-east-2-notification-arn", "NotificationEvents": [ "All" ], "NotificationType": "Invocation" }, "RequestedDateTime": 1579893879.775, "ServiceRole": "arn:aws:iam::111122223333:role/my-SNS-notifications-role", "StandardErrorUrl": "https://s3.us-east-2.amazonaws.com/amzn-s3-demo-bucket/my-output/1231bb3b-fe26-48ea-94fe-d1727EXAMPLE/i-02573cafcfEXAMPLE/awsrunPowerShellScript/0.awsrunPowerShellScript/stderr", "StandardOutputUrl": "https://s3.us-east-2.amazonaws.com/amzn-s3-demo-bucket/my-output/1231bb3b-fe26-48ea-94fe-d1727EXAMPLE/i-02573cafcfEXAMPLE/awsrunPowerShellScript/0.awsrunPowerShellScript/stdout", "Status": "Success", "StatusDetails": "Success" }, { "CloudWatchOutputConfig": { "CloudWatchLogGroupName": "", "CloudWatchOutputEnabled": false }, "CommandId": "4171bb3b-fe26-48ea-94fe-d1727EXAMPLE", "CommandPlugins": [], "Comment": "", "DocumentName": "AWS-FindWindowsUpdates", "DocumentVersion": "1", "InstanceId": "i-0471e04240EXAMPLE", "InstanceName": "EXAMPLE-A1PDOM8.WORKGROUP", "NotificationConfig": { "NotificationArn": "arn:aws:sns:us-east-2:111122223333:my-us-east-2-notification-arn", "NotificationEvents": [ "All" ], "NotificationType": "Invocation" }, "RequestedDateTime": 1579893879.6, "ServiceRole": "arn:aws:iam::111122223333:role/my-SNS-notifications-role", "StandardErrorUrl": "https://s3.us-east-2.amazonaws.com/amzn-s3-demo-bucket/my-output/4171bb3b-fe26-48ea-94fe-d1727EXAMPLE/i-0471e04240EXAMPLE/awsrunPowerShellScript/0.awsrunPowerShellScript/stderr", "StandardOutputUrl": "https://s3.us-east-2.amazonaws.com/amzn-s3-demo-bucket/my-output/4171bb3b-fe26-48ea-94fe-d1727EXAMPLE/i-0471e04240EXAMPLE/awsrunPowerShellScript/0.awsrunPowerShellScript/stdout", "Status": "Success", "StatusDetails": "Success" } ] }

See Also

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