Skip to content

start_automation_execution

start_automation_execution(
    document_name: DocumentARN,
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    document_version: Optional[DocumentVersion] = None,
    parameters: Optional[AutomationParameterMap] = None,
    client_token: Optional[IdempotencyToken] = None,
    mode: Optional[ExecutionMode] = None,
    target_parameter_name: Optional[AutomationParameterKey] = None,
    targets: Optional[AutomationTargets] = None,
    target_maps: Optional[TargetMaps] = None,
    max_concurrency: Optional[MaxConcurrency] = None,
    max_errors: Optional[MaxErrors] = None,
    target_locations: Optional[TargetLocations] = None,
    tags: Optional[TagList] = None,
    alarm_configuration: Optional[AlarmConfiguration] = None,
    target_locations_url: Optional[TargetLocationsURL] = None,
) -> StartAutomationExecutionResult

Initiates execution of an Automation runbook.

Parameters:

  • document_name (DocumentARN) –

    The name of the 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 ARN. For more information about how to use shared documents, see Sharing SSM documents in the Amazon Web Services Systems Manager User Guide.

  • document_version (Optional[DocumentVersion], default: None ) –

    The version of the Automation runbook to use for this execution.

  • parameters (Optional[AutomationParameterMap], default: None ) –

    A key-value map of execution parameters, which match the declared parameters in the Automation runbook.

  • client_token (Optional[IdempotencyToken], default: None ) –

    User-provided idempotency token. The token must be unique, is case insensitive, enforces the UUID format, and can't be reused.

  • mode (Optional[ExecutionMode], default: None ) –

    The execution mode of the automation. Valid modes include the following: Auto and Interactive. The default mode is Auto.

  • target_parameter_name (Optional[AutomationParameterKey], default: None ) –

    The name of the parameter used as the target resource for the rate-controlled execution. Required if you specify targets.

  • targets (Optional[AutomationTargets], default: None ) –

    A key-value mapping to target resources. Required if you specify TargetParameterName.

    If both this parameter and the TargetLocation:Targets parameter are supplied, TargetLocation:Targets takes precedence.

  • target_maps (Optional[TargetMaps], default: None ) –

    A key-value mapping of document parameters to target resources. Both Targets and TargetMaps can't be specified together.

  • max_concurrency (Optional[MaxConcurrency], default: None ) –

    The maximum number of targets allowed to run this task in parallel. You can specify a number, such as 10, or a percentage, such as 10%. The default value is 10.

    If both this parameter and the TargetLocation:TargetsMaxConcurrency are supplied, TargetLocation:TargetsMaxConcurrency takes precedence.

  • max_errors (Optional[MaxErrors], default: None ) –

    The number of errors that are allowed before the system stops running the automation on additional targets. You can specify either an absolute number of errors, for example 10, or a percentage of the target set, for example 10%. If you specify 3, for example, the system stops running the automation when the fourth error is received. If you specify 0, then the system stops running the automation on additional targets after the first error result is returned. If you run an automation on 50 resources and set max-errors to 10%, then the system stops running the automation on additional targets when the sixth error is received.

    Executions that are already running an automation when max-errors is reached are allowed to complete, but some of these executions may fail as well. If you need to ensure that there won't be more than max-errors failed executions, set max-concurrency to 1 so the executions proceed one at a time.

    If this parameter and the TargetLocation:TargetsMaxErrors parameter are both supplied, TargetLocation:TargetsMaxErrors takes precedence.

  • target_locations (Optional[TargetLocations], default: None ) –

    A location is a combination of Amazon Web Services Regions and/or Amazon Web Services accounts where you want to run the automation. Use this operation to start an automation in multiple Amazon Web Services Regions and multiple Amazon Web Services accounts. For more information, see Running automations in multiple Amazon Web Services Regions and accounts in the Amazon Web Services Systems Manager User Guide.

  • tags (Optional[TagList], default: None ) –

    Optional metadata that you assign to a resource. You can specify a maximum of five tags for an automation. Tags enable you to categorize a resource in different ways, such as by purpose, owner, or environment. For example, you might want to tag an automation to identify an environment or operating system. In this case, you could specify the following key-value pairs:

    • Key=environment,Value=test

    • Key=OS,Value=Windows

    The Array Members maximum value is reported as 1000. This number includes capacity reserved for internal operations. When calling the StartAutomationExecution action, you can specify a maximum of 5 tags. You can, however, use the AddTagsToResource action to add up to a total of 50 tags to an existing automation configuration.

  • alarm_configuration (Optional[AlarmConfiguration], default: None ) –

    The CloudWatch alarm you want to apply to your automation.

  • target_locations_url (Optional[TargetLocationsURL], default: None ) –

    Specify a publicly accessible URL for a file that contains the TargetLocations body. Currently, only files in presigned Amazon S3 buckets are supported.

Raises:

Source code in docs_src/capo_ssm/_services/ssm.py
def start_automation_execution(
    self,
    document_name: "capo_ssm.types.document_arn.DocumentARN",
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    document_version: Optional[
        "capo_ssm.types.document_version.DocumentVersion"
    ] = None,
    parameters: Optional[
        "capo_ssm.types.automation_parameter_map.AutomationParameterMap"
    ] = None,
    client_token: Optional[
        "capo_ssm.types.idempotency_token.IdempotencyToken"
    ] = None,
    mode: Optional["capo_ssm.types.execution_mode.ExecutionMode"] = None,
    target_parameter_name: Optional[
        "capo_ssm.types.automation_parameter_key.AutomationParameterKey"
    ] = None,
    targets: Optional["capo_ssm.types.automation_targets.AutomationTargets"] = None,
    target_maps: Optional["capo_ssm.types.target_maps.TargetMaps"] = None,
    max_concurrency: Optional[
        "capo_ssm.types.max_concurrency.MaxConcurrency"
    ] = None,
    max_errors: Optional["capo_ssm.types.max_errors.MaxErrors"] = None,
    target_locations: Optional[
        "capo_ssm.types.target_locations.TargetLocations"
    ] = None,
    tags: Optional["capo_ssm.types.tag_list.TagList"] = None,
    alarm_configuration: Optional[
        "capo_ssm.types.alarm_configuration.AlarmConfiguration"
    ] = None,
    target_locations_url: Optional[
        "capo_ssm.types.target_locations_url.TargetLocationsURL"
    ] = None,
) -> "capo_ssm.types.start_automation_execution_result.StartAutomationExecutionResult":
    """<p>Initiates execution of an Automation runbook.</p>

    Args:
        document_name: <p>The name of the 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 ARN. For more information about how to use shared documents, see <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/documents-ssm-sharing.html">Sharing SSM documents</a> in the <i>Amazon Web Services Systems Manager User Guide</i>.</p>
        document_version: <p>The version of the Automation runbook to use for this execution.</p>
        parameters: <p>A key-value map of execution parameters, which match the declared parameters in the Automation runbook.</p>
        client_token: <p>User-provided idempotency token. The token must be unique, is case insensitive, enforces the UUID format, and can't be reused.</p>
        mode: <p>The execution mode of the automation. Valid modes include the following: Auto and Interactive. The default mode is Auto.</p>
        target_parameter_name: <p>The name of the parameter used as the target resource for the rate-controlled execution. Required if you specify targets.</p>
        targets: <p>A key-value mapping to target resources. Required if you specify TargetParameterName.</p> <p>If both this parameter and the <code>TargetLocation:Targets</code> parameter are supplied, <code>TargetLocation:Targets</code> takes precedence.</p>
        target_maps: <p>A key-value mapping of document parameters to target resources. Both Targets and TargetMaps can't be specified together.</p>
        max_concurrency: <p>The maximum number of targets allowed to run this task in parallel. You can specify a number, such as 10, or a percentage, such as 10%. The default value is <code>10</code>.</p> <p>If both this parameter and the <code>TargetLocation:TargetsMaxConcurrency</code> are supplied, <code>TargetLocation:TargetsMaxConcurrency</code> takes precedence.</p>
        max_errors: <p>The number of errors that are allowed before the system stops running the automation on additional targets. You can specify either an absolute number of errors, for example 10, or a percentage of the target set, for example 10%. If you specify 3, for example, the system stops running the automation when the fourth error is received. If you specify 0, then the system stops running the automation on additional targets after the first error result is returned. If you run an automation on 50 resources and set max-errors to 10%, then the system stops running the automation on additional targets when the sixth error is received.</p> <p>Executions that are already running an automation when max-errors is reached are allowed to complete, but some of these executions may fail as well. If you need to ensure that there won't be more than max-errors failed executions, set max-concurrency to 1 so the executions proceed one at a time.</p> <p>If this parameter and the <code>TargetLocation:TargetsMaxErrors</code> parameter are both supplied, <code>TargetLocation:TargetsMaxErrors</code> takes precedence.</p>
        target_locations: <p>A location is a combination of Amazon Web Services Regions and/or Amazon Web Services accounts where you want to run the automation. Use this operation to start an automation in multiple Amazon Web Services Regions and multiple Amazon Web Services accounts. For more information, see <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-automation-multiple-accounts-and-regions.html">Running automations in multiple Amazon Web Services Regions and accounts</a> in the <i>Amazon Web Services Systems Manager User Guide</i>. </p>
        tags: <p>Optional metadata that you assign to a resource. You can specify a maximum of five tags for an automation. Tags enable you to categorize a resource in different ways, such as by purpose, owner, or environment. For example, you might want to tag an automation to identify an environment or operating system. In this case, you could specify the following key-value pairs:</p> <ul> <li> <p> <code>Key=environment,Value=test</code> </p> </li> <li> <p> <code>Key=OS,Value=Windows</code> </p> </li> </ul> <note> <p>The <code>Array Members</code> maximum value is reported as 1000. This number includes capacity reserved for internal operations. When calling the <code>StartAutomationExecution</code> action, you can specify a maximum of 5 tags. You can, however, use the <a>AddTagsToResource</a> action to add up to a total of 50 tags to an existing automation configuration.</p> </note>
        alarm_configuration: <p>The CloudWatch alarm you want to apply to your automation.</p>
        target_locations_url: <p>Specify a publicly accessible URL for a file that contains the <code>TargetLocations</code> body. Currently, only files in presigned Amazon S3 buckets are supported. </p>

    Raises:
        capo_ssm.errors.automation_definition_not_found_exception.AutomationDefinitionNotFoundException: <p>An Automation runbook with the specified name couldn't be found.</p>
        capo_ssm.errors.automation_definition_version_not_found_exception.AutomationDefinitionVersionNotFoundException: <p>An Automation runbook with the specified name and version couldn't be found.</p>
        capo_ssm.errors.automation_execution_limit_exceeded_exception.AutomationExecutionLimitExceededException: <p>The number of simultaneously running Automation executions exceeded the allowable limit.</p>
        capo_ssm.errors.idempotent_parameter_mismatch.IdempotentParameterMismatch: <p>Error returned when an idempotent operation is retried and the parameters don't match the original call to the API with the same idempotency token. </p>
        capo_ssm.errors.internal_server_error.InternalServerError: <p>An error occurred on the server side.</p>
        capo_ssm.errors.invalid_automation_execution_parameters_exception.InvalidAutomationExecutionParametersException: <p>The supplied parameters for invoking the specified Automation runbook are incorrect. For example, they may not match the set of parameters permitted for the specified Automation document.</p>
        capo_ssm.errors.invalid_target.InvalidTarget: <p>The target isn't valid or doesn't exist. It might not be configured for Systems Manager or you might not have permission to perform the operation.</p>
        capo_ssm.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ssm.types.start_automation_execution_request.StartAutomationExecutionRequest]",
    ) -> OperationResponse[
        "capo_ssm.types.start_automation_execution_result.StartAutomationExecutionResult"
    ]:
        import capo_ssm._operations.amazon_ssm.start_automation_execution

        output, http_response = (
            capo_ssm._operations.amazon_ssm.start_automation_execution.start_automation_execution(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("StartAutomationExecution")
    )
    input_: capo_ssm.types.start_automation_execution_request.StartAutomationExecutionRequest = {
        "document_name": document_name
    }
    if document_version is not None:
        input_["document_version"] = document_version
    if parameters is not None:
        input_["parameters"] = parameters
    if client_token is not None:
        input_["client_token"] = client_token
    if mode is not None:
        input_["mode"] = mode
    if target_parameter_name is not None:
        input_["target_parameter_name"] = target_parameter_name
    if targets is not None:
        input_["targets"] = targets
    if target_maps is not None:
        input_["target_maps"] = target_maps
    if max_concurrency is not None:
        input_["max_concurrency"] = max_concurrency
    if max_errors is not None:
        input_["max_errors"] = max_errors
    if target_locations is not None:
        input_["target_locations"] = target_locations
    if tags is not None:
        input_["tags"] = tags
    if alarm_configuration is not None:
        input_["alarm_configuration"] = alarm_configuration
    if target_locations_url is not None:
        input_["target_locations_url"] = target_locations_url

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output