SSM / Client / start_automation_execution

start_automation_execution#

SSM.Client.start_automation_execution(**kwargs)#

Initiates execution of an Automation runbook.

See also: AWS API Documentation

Request Syntax

response = client.start_automation_execution(
    DocumentName='string',
    DocumentVersion='string',
    Parameters={
        'string': [
            'string',
        ]
    },
    ClientToken='string',
    Mode='Auto'|'Interactive',
    TargetParameterName='string',
    Targets=[
        {
            'Key': 'string',
            'Values': [
                'string',
            ]
        },
    ],
    TargetMaps=[
        {
            'string': [
                'string',
            ]
        },
    ],
    MaxConcurrency='string',
    MaxErrors='string',
    TargetLocations=[
        {
            'Accounts': [
                'string',
            ],
            'Regions': [
                'string',
            ],
            'TargetLocationMaxConcurrency': 'string',
            'TargetLocationMaxErrors': 'string',
            'ExecutionRoleName': 'string',
            'TargetLocationAlarmConfiguration': {
                'IgnorePollAlarmFailure': True|False,
                'Alarms': [
                    {
                        'Name': 'string'
                    },
                ]
            }
        },
    ],
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ],
    AlarmConfiguration={
        'IgnorePollAlarmFailure': True|False,
        'Alarms': [
            {
                'Name': 'string'
            },
        ]
    }
)
Parameters:
  • DocumentName (string) –

    [REQUIRED]

    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.

  • DocumentVersion (string) – The version of the Automation runbook to use for this execution.

  • Parameters (dict) –

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

    • (string) –

      • (list) –

        • (string) –

  • ClientToken (string) – User-provided idempotency token. The token must be unique, is case insensitive, enforces the UUID format, and can’t be reused.

  • Mode (string) – The execution mode of the automation. Valid modes include the following: Auto and Interactive. The default mode is Auto.

  • TargetParameterName (string) – The name of the parameter used as the target resource for the rate-controlled execution. Required if you specify targets.

  • Targets (list) –

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

    • (dict) –

      An array of search criteria that targets managed nodes using a key-value pair that you specify.

      Note

      One or more targets must be specified for maintenance window Run Command-type tasks. Depending on the task, targets are optional for other maintenance window task types (Automation, Lambda, and Step Functions). For more information about running tasks that don’t specify targets, see Registering maintenance window tasks without targets in the Amazon Web Services Systems Manager User Guide.

      Supported formats include the following.

      • Key=InstanceIds,Values=<instance-id-1>,<instance-id-2>,<instance-id-3>

      • Key=tag:<my-tag-key>,Values=<my-tag-value-1>,<my-tag-value-2>

      • Key=tag-key,Values=<my-tag-key-1>,<my-tag-key-2>

      • Run Command and Maintenance window targets only: Key=resource-groups:Name,Values=<resource-group-name>

      • Maintenance window targets only: Key=resource-groups:ResourceTypeFilters,Values=<resource-type-1>,<resource-type-2>

      • Automation targets only: Key=ResourceGroup;Values=<resource-group-name>

      For example:

      • Key=InstanceIds,Values=i-02573cafcfEXAMPLE,i-0471e04240EXAMPLE,i-07782c72faEXAMPLE

      • Key=tag:CostCenter,Values=CostCenter1,CostCenter2,CostCenter3

      • Key=tag-key,Values=Name,Instance-Type,CostCenter

      • Run Command and Maintenance window targets only: Key=resource-groups:Name,Values=ProductionResourceGroup This example demonstrates how to target all resources in the resource group ProductionResourceGroup in your maintenance window.

      • Maintenance window targets only: Key=resource-groups:ResourceTypeFilters,Values=AWS::EC2::INSTANCE,AWS::EC2::VPC This example demonstrates how to target only Amazon Elastic Compute Cloud (Amazon EC2) instances and VPCs in your maintenance window.

      • Automation targets only: Key=ResourceGroup,Values=MyResourceGroup

      • State Manager association targets only: Key=InstanceIds,Values=* This example demonstrates how to target all managed instances in the Amazon Web Services Region where the association was created.

      For more information about how to send commands that target managed nodes using Key,Value parameters, see Targeting multiple managed nodes in the Amazon Web Services Systems Manager User Guide.

      • Key (string) –

        User-defined criteria for sending commands that target managed nodes that meet the criteria.

      • Values (list) –

        User-defined criteria that maps to Key. For example, if you specified tag:ServerRole, you could specify value:WebServer to run a command on instances that include EC2 tags of ServerRole,WebServer.

        Depending on the type of target, the maximum number of values for a key might be lower than the global maximum of 50.

        • (string) –

  • TargetMaps (list) –

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

    • (dict) –

      • (string) –

        • (list) –

          • (string) –

  • MaxConcurrency (string) – 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.

  • MaxErrors (string) –

    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.

  • TargetLocations (list) –

    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 Automation workflows in multiple Amazon Web Services Regions and Amazon Web Services accounts in the Amazon Web Services Systems Manager User Guide.

    • (dict) –

      The combination of Amazon Web Services Regions and Amazon Web Services accounts targeted by the current Automation execution.

      • Accounts (list) –

        The Amazon Web Services accounts targeted by the current Automation execution.

        • (string) –

      • Regions (list) –

        The Amazon Web Services Regions targeted by the current Automation execution.

        • (string) –

      • TargetLocationMaxConcurrency (string) –

        The maximum number of Amazon Web Services Regions and Amazon Web Services accounts allowed to run the Automation concurrently.

      • TargetLocationMaxErrors (string) –

        The maximum number of errors allowed before the system stops queueing additional Automation executions for the currently running Automation.

      • ExecutionRoleName (string) –

        The Automation execution role used by the currently running Automation. If not specified, the default value is AWS-SystemsManager-AutomationExecutionRole.

      • TargetLocationAlarmConfiguration (dict) –

        The details for the CloudWatch alarm you want to apply to an automation or command.

        • IgnorePollAlarmFailure (boolean) –

          When this value is true, your automation or command continues to run in cases where we can’t retrieve alarm status information from CloudWatch. In cases where we successfully retrieve an alarm status of OK or INSUFFICIENT_DATA, the automation or command continues to run, regardless of this value. Default is false.

        • Alarms (list) – [REQUIRED]

          The name of the CloudWatch alarm specified in the configuration.

          • (dict) –

            A CloudWatch alarm you apply to an automation or command.

            • Name (string) – [REQUIRED]

              The name of your CloudWatch alarm.

  • Tags (list) –

    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

    Note

    To add tags to an existing automation, use the AddTagsToResource operation.

    • (dict) –

      Metadata that you assign to your Amazon Web Services resources. Tags enable you to categorize your resources in different ways, for example, by purpose, owner, or environment. In Amazon Web Services Systems Manager, you can apply tags to Systems Manager documents (SSM documents), managed nodes, maintenance windows, parameters, patch baselines, OpsItems, and OpsMetadata.

      • Key (string) – [REQUIRED]

        The name of the tag.

      • Value (string) – [REQUIRED]

        The value of the tag.

  • AlarmConfiguration (dict) –

    The CloudWatch alarm you want to apply to your automation.

    • IgnorePollAlarmFailure (boolean) –

      When this value is true, your automation or command continues to run in cases where we can’t retrieve alarm status information from CloudWatch. In cases where we successfully retrieve an alarm status of OK or INSUFFICIENT_DATA, the automation or command continues to run, regardless of this value. Default is false.

    • Alarms (list) – [REQUIRED]

      The name of the CloudWatch alarm specified in the configuration.

      • (dict) –

        A CloudWatch alarm you apply to an automation or command.

        • Name (string) – [REQUIRED]

          The name of your CloudWatch alarm.

Return type:

dict

Returns:

Response Syntax

{
    'AutomationExecutionId': 'string'
}

Response Structure

  • (dict) –

    • AutomationExecutionId (string) –

      The unique ID of a newly scheduled automation execution.

Exceptions

  • SSM.Client.exceptions.AutomationDefinitionNotFoundException

  • SSM.Client.exceptions.InvalidAutomationExecutionParametersException

  • SSM.Client.exceptions.AutomationExecutionLimitExceededException

  • SSM.Client.exceptions.AutomationDefinitionVersionNotFoundException

  • SSM.Client.exceptions.IdempotentParameterMismatch

  • SSM.Client.exceptions.InvalidTarget

  • SSM.Client.exceptions.InternalServerError