send_command
¶
send_command(
document_name: DocumentARN,
*,
config_overrides: Optional[SSMClientConfig] = 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/ssm.py
10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 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 | |