send_command
async
¶
send_command(
document_name: DocumentARN,
*,
config_overrides: Optional[AsyncSSMClientConfig] = None,
instance_ids: Optional[InstanceIdList] = None,
targets: Optional[Targets] = None,
document_version: Optional[DocumentVersion] = None,
document_hash: Optional[DocumentHash] = None,
document_hash_type: Optional[DocumentHashType] = None,
timeout_seconds: Optional[TimeoutSeconds] = None,
comment: Optional[Comment] = None,
parameters: Optional[Parameters] = None,
output_s3_region: Optional[S3Region] = None,
output_s3_bucket_name: Optional[S3BucketName] = None,
output_s3_key_prefix: Optional[S3KeyPrefix] = None,
max_concurrency: Optional[MaxConcurrency] = None,
max_errors: Optional[MaxErrors] = None,
service_role_arn: Optional[ServiceRole] = None,
notification_config: Optional[NotificationConfig] = None,
cloud_watch_output_config: Optional[CloudWatchOutputConfig] = None,
alarm_configuration: Optional[AlarmConfiguration] = None,
) -> SendCommandResult
Runs commands on one or more managed nodes.
Parameters:
-
instance_ids(Optional[InstanceIdList], default:None) –The IDs of the managed nodes where the command should run. Specifying managed node IDs is most useful when you are targeting a limited number of managed nodes, though you can specify up to 50 IDs.
To target a larger number of managed nodes, or if you prefer not to list individual node IDs, we recommend using the
Targetsoption instead. UsingTargets, which accepts tag key-value pairs to identify the managed nodes to send commands to, you can a send command to tens, hundreds, or thousands of nodes at once.For more information about how to use targets, see Run commands at scale in the Amazon Web Services Systems Manager User Guide.
-
targets(Optional[Targets], default:None) –An array of search criteria that targets managed nodes using a
Key,Valuecombination that you specify. Specifying targets is most useful when you want to send a command to a large number of managed nodes at once. UsingTargets, which accepts tag key-value pairs to identify managed nodes, you can send a command to tens, hundreds, or thousands of nodes at once.To send a command to a smaller number of managed nodes, you can use the
InstanceIdsoption instead.For more information about how to use targets, see Run commands at scale in the Amazon Web Services Systems Manager User Guide.
-
document_name(DocumentARN) –The name of the Amazon Web Services Systems Manager document (SSM document) to run. This can be a public document or a custom document. To run a shared document belonging to another account, specify the document Amazon Resource Name (ARN). For more information about how to use shared documents, see Sharing SSM documents in the Amazon Web Services Systems Manager User Guide.
If you specify a document name or ARN that hasn't been shared with your account, you receive an
InvalidDocumenterror. -
document_version(Optional[DocumentVersion], default:None) –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 Command Line Interface (Amazon Web Services 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"
-
document_hash(Optional[DocumentHash], default:None) –The Sha256 or Sha1 hash created by the system when the document was created.
Sha1 hashes have been deprecated.
-
document_hash_type(Optional[DocumentHashType], default:None) –Sha256 or Sha1.
Sha1 hashes have been deprecated.
-
timeout_seconds(Optional[TimeoutSeconds], default:None) –If this time is reached and the command hasn't already started running, it won't run.
-
comment(Optional[Comment], default:None) –User-specified information about the command, such as a brief description of what the command should do.
-
parameters(Optional[Parameters], default:None) –The required and optional parameters specified in the document being run.
-
output_s3_region(Optional[S3Region], default:None) –(Deprecated) You can no longer specify this parameter. The system ignores it. Instead, Systems Manager automatically determines the Amazon Web Services Region of the S3 bucket.
-
output_s3_bucket_name(Optional[S3BucketName], default:None) –The name of the S3 bucket where command execution responses should be stored.
-
output_s3_key_prefix(Optional[S3KeyPrefix], default:None) –The directory structure within the S3 bucket where the responses should be stored.
-
max_concurrency(Optional[MaxConcurrency], default:None) –(Optional) The maximum number of managed nodes 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 useMaxConcurrency, see Using concurrency controls in the Amazon Web Services Systems Manager User Guide. -
max_errors(Optional[MaxErrors], default:None) –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 is0. For more information about how to useMaxErrors, see Using error controls in the Amazon Web Services Systems Manager User Guide. -
service_role_arn(Optional[ServiceRole], default:None) –The ARN of the Identity and Access Management (IAM) service role to use to publish Amazon Simple Notification Service (Amazon SNS) notifications for Run Command commands.
This role must provide the
sns:Publishpermission for your notification topic. For information about creating and using this service role, see Monitoring Systems Manager status changes using Amazon SNS notifications in the Amazon Web Services Systems Manager User Guide. -
notification_config(Optional[NotificationConfig], default:None) –Configurations for sending notifications.
-
cloud_watch_output_config(Optional[CloudWatchOutputConfig], default:None) –Enables Amazon Web Services Systems Manager to send Run Command output to Amazon CloudWatch Logs. Run Command is a tool in Amazon Web Services Systems Manager.
-
alarm_configuration(Optional[AlarmConfiguration], default:None) –The CloudWatch alarm you want to apply to your command.
Raises:
-
DuplicateInstanceId–You can't specify a managed node ID in more than one association.
-
InternalServerError–An error occurred on the server side.
-
InvalidDocument–The specified SSM document doesn't exist.
-
InvalidDocumentVersion–The document version isn't valid or doesn't exist.
-
InvalidInstanceId–The following problems can cause this exception:
-
You don't have permission to access the managed node.
-
Amazon Web Services 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, andStopping. Invalid states are:Shutting-downandTerminated.
-
-
InvalidNotificationConfig–One or more configuration items isn't valid. Verify that a valid Amazon Resource Name (ARN) was provided for an Amazon Simple Notification Service topic.
-
InvalidOutputFolder–The S3 bucket doesn't exist.
-
InvalidParameters–You must specify values for all required parameters in the Amazon Web Services Systems Manager document (SSM document). You can only supply values to parameters defined in the SSM document.
-
InvalidRole–The role name can't contain invalid characters. Also verify that you specified an IAM role for notifications that includes the required trust policy. For information about configuring the IAM role for Run Command notifications, see Monitoring Systems Manager status changes using Amazon SNS notifications in the Amazon Web Services Systems Manager User Guide.
-
MaxDocumentSizeExceeded–The size limit of a document is 64 KB.
-
UnsupportedPlatformType–The document doesn't support the platform type of the given managed node IDs. For example, you sent an document for a Windows managed node to a Linux node.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_ssm/_services/async_ssm.py
10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 | |