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
10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 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 | |