Skip to content

update_maintenance_window_task async

update_maintenance_window_task(
    window_id: MaintenanceWindowId,
    window_task_id: MaintenanceWindowTaskId,
    *,
    config_overrides: Optional[AsyncSSMClientConfig] = None,
    targets: Optional[Targets] = None,
    task_arn: Optional[MaintenanceWindowTaskArn] = None,
    service_role_arn: Optional[ServiceRole] = None,
    task_parameters: Optional[MaintenanceWindowTaskParameters] = None,
    task_invocation_parameters: Optional[
        MaintenanceWindowTaskInvocationParameters
    ] = None,
    priority: Optional[MaintenanceWindowTaskPriority] = None,
    max_concurrency: Optional[MaxConcurrency] = None,
    max_errors: Optional[MaxErrors] = None,
    logging_info: Optional[LoggingInfo] = None,
    name: Optional[MaintenanceWindowName] = None,
    description: Optional[MaintenanceWindowDescription] = None,
    replace: Optional[Boolean] = None,
    cutoff_behavior: Optional[MaintenanceWindowTaskCutoffBehavior] = None,
    alarm_configuration: Optional[AlarmConfiguration] = None,
) -> UpdateMaintenanceWindowTaskResult

Modifies a task assigned to a maintenance window. You can't change the task type, but you can change the following values:

  • TaskARN. For example, you can change a RUN_COMMAND task from AWS-RunPowerShellScript to AWS-RunShellScript.

  • ServiceRoleArn

  • TaskInvocationParameters

  • Priority

  • MaxConcurrency

  • MaxErrors

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.

If the value for a parameter in UpdateMaintenanceWindowTask is null, then the corresponding field isn't modified. If you set Replace to true, then all fields required by the RegisterTaskWithMaintenanceWindow operation are required for this request. Optional fields that aren't specified are set to null.

When you update a maintenance window task that has options specified in TaskInvocationParameters, you must provide again all the TaskInvocationParameters values that you want to retain. The values you don't specify again are removed. For example, suppose that when you registered a Run Command task, you specified TaskInvocationParameters values for Comment, NotificationConfig, and OutputS3BucketName. If you update the maintenance window task and specify only a different OutputS3BucketName value, the values for Comment and NotificationConfig are removed.

Parameters:

  • window_id (MaintenanceWindowId) –

    The maintenance window ID that contains the task to modify.

  • window_task_id (MaintenanceWindowTaskId) –

    The task ID to modify.

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

    The targets (either managed nodes or tags) to modify. Managed nodes are specified using the format Key=instanceids,Values=instanceID_1,instanceID_2. Tags are specified using the format Key=tag_name,Values=tag_value.

    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.

  • task_arn (Optional[MaintenanceWindowTaskArn], default: None ) –

    The task ARN to modify.

  • service_role_arn (Optional[ServiceRole], default: None ) –

    The Amazon Resource Name (ARN) of the IAM service role for Amazon Web Services Systems Manager to assume when running a maintenance window task. If you do not specify a service role ARN, Systems Manager uses a service-linked role in your account. If no appropriate service-linked role for Systems Manager exists in your account, it is created when you run RegisterTaskWithMaintenanceWindow.

    However, for an improved security posture, we strongly recommend creating a custom policy and custom service role for running your maintenance window tasks. The policy can be crafted to provide only the permissions needed for your particular maintenance window tasks. For more information, see Setting up Maintenance Windows in the in the Amazon Web Services Systems Manager User Guide.

  • task_parameters (Optional[MaintenanceWindowTaskParameters], default: None ) –

    The parameters to modify.

    TaskParameters has been deprecated. To specify parameters to pass to a task when it runs, instead use the Parameters option in the TaskInvocationParameters structure. For information about how Systems Manager handles these options for the supported maintenance window task types, see MaintenanceWindowTaskInvocationParameters.

    The map has the following format:

    Key: string, between 1 and 255 characters

    Value: an array of strings, each string is between 1 and 255 characters

  • task_invocation_parameters (Optional[MaintenanceWindowTaskInvocationParameters], default: None ) –

    The parameters that the task should use during execution. Populate only the fields that match the task type. All other fields should be empty.

    When you update a maintenance window task that has options specified in TaskInvocationParameters, you must provide again all the TaskInvocationParameters values that you want to retain. The values you don't specify again are removed. For example, suppose that when you registered a Run Command task, you specified TaskInvocationParameters values for Comment, NotificationConfig, and OutputS3BucketName. If you update the maintenance window task and specify only a different OutputS3BucketName value, the values for Comment and NotificationConfig are removed.

  • priority (Optional[MaintenanceWindowTaskPriority], default: None ) –

    The new task priority to specify. The lower the number, the higher the priority. Tasks that have the same priority are scheduled in parallel.

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

    The new MaxConcurrency value you want to specify. MaxConcurrency is the number of targets that are allowed to run this task, in parallel.

    Although this element is listed as "Required: No", a value can be omitted only when you are registering or updating a targetless task You must provide a value in all other cases.

    For maintenance window tasks without a target specified, you can't supply a value for this option. Instead, the system inserts a placeholder value of 1. This value doesn't affect the running of your task.

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

    The new MaxErrors value to specify. MaxErrors is the maximum number of errors that are allowed before the task stops being scheduled.

    Although this element is listed as "Required: No", a value can be omitted only when you are registering or updating a targetless task You must provide a value in all other cases.

    For maintenance window tasks without a target specified, you can't supply a value for this option. Instead, the system inserts a placeholder value of 1. This value doesn't affect the running of your task.

  • logging_info (Optional[LoggingInfo], default: None ) –

    The new logging location in Amazon S3 to specify.

    LoggingInfo has been deprecated. To specify an Amazon Simple Storage Service (Amazon S3) bucket to contain logs, instead use the OutputS3BucketName and OutputS3KeyPrefix options in the TaskInvocationParameters structure. For information about how Amazon Web Services Systems Manager handles these options for the supported maintenance window task types, see MaintenanceWindowTaskInvocationParameters.

  • name (Optional[MaintenanceWindowName], default: None ) –

    The new task name to specify.

  • description (Optional[MaintenanceWindowDescription], default: None ) –

    The new task description to specify.

  • replace (Optional[Boolean], default: None ) –

    If True, then all fields that are required by the RegisterTaskWithMaintenanceWindow operation are also required for this API request. Optional fields that aren't specified are set to null.

  • cutoff_behavior (Optional[MaintenanceWindowTaskCutoffBehavior], default: None ) –

    Indicates whether tasks should continue to run after the cutoff time specified in the maintenance windows is reached.

    • CONTINUE_TASK: When the cutoff time is reached, any tasks that are running continue. The default value.

    • CANCEL_TASK:

      • For Automation, Lambda, Step Functions tasks: When the cutoff time is reached, any task invocations that are already running continue, but no new task invocations are started.

      • For Run Command tasks: When the cutoff time is reached, the system sends a CancelCommand operation that attempts to cancel the command associated with the task. However, there is no guarantee that the command will be terminated and the underlying process stopped.

      The status for tasks that are not completed is TIMED_OUT.

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

    The CloudWatch alarm you want to apply to your maintenance window task.

Raises:

  • DoesNotExistException –

    Error returned when the ID specified for a resource, such as a maintenance window or patch baseline, doesn't exist.

    For information about resource quotas in Amazon Web Services Systems Manager, see Systems Manager service quotas in the Amazon Web Services General Reference.

  • InternalServerError –

    An error occurred on the server side.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_ssm/_services/async_ssm.py
async def update_maintenance_window_task(
    self,
    window_id: "capo_ssm.types.maintenance_window_id.MaintenanceWindowId",
    window_task_id: "capo_ssm.types.maintenance_window_task_id.MaintenanceWindowTaskId",
    *,
    config_overrides: Optional[AsyncSSMClientConfig] = None,
    targets: Optional["capo_ssm.types.targets.Targets"] = None,
    task_arn: Optional[
        "capo_ssm.types.maintenance_window_task_arn.MaintenanceWindowTaskArn"
    ] = None,
    service_role_arn: Optional["capo_ssm.types.service_role.ServiceRole"] = None,
    task_parameters: Optional[
        "capo_ssm.types.maintenance_window_task_parameters.MaintenanceWindowTaskParameters"
    ] = None,
    task_invocation_parameters: Optional[
        "capo_ssm.types.maintenance_window_task_invocation_parameters.MaintenanceWindowTaskInvocationParameters"
    ] = None,
    priority: Optional[
        "capo_ssm.types.maintenance_window_task_priority.MaintenanceWindowTaskPriority"
    ] = None,
    max_concurrency: Optional[
        "capo_ssm.types.max_concurrency.MaxConcurrency"
    ] = None,
    max_errors: Optional["capo_ssm.types.max_errors.MaxErrors"] = None,
    logging_info: Optional["capo_ssm.types.logging_info.LoggingInfo"] = None,
    name: Optional[
        "capo_ssm.types.maintenance_window_name.MaintenanceWindowName"
    ] = None,
    description: Optional[
        "capo_ssm.types.maintenance_window_description.MaintenanceWindowDescription"
    ] = None,
    replace: Optional["capo_ssm.types.boolean.Boolean"] = None,
    cutoff_behavior: Optional[
        "capo_ssm.types.maintenance_window_task_cutoff_behavior.MaintenanceWindowTaskCutoffBehavior"
    ] = None,
    alarm_configuration: Optional[
        "capo_ssm.types.alarm_configuration.AlarmConfiguration"
    ] = None,
) -> "capo_ssm.types.update_maintenance_window_task_result.UpdateMaintenanceWindowTaskResult":
    """<p>Modifies a task assigned to a maintenance window. You can't change the task type, but you can change the following values:</p> <ul> <li> <p> <code>TaskARN</code>. For example, you can change a <code>RUN_COMMAND</code> task from <code>AWS-RunPowerShellScript</code> to <code>AWS-RunShellScript</code>.</p> </li> <li> <p> <code>ServiceRoleArn</code> </p> </li> <li> <p> <code>TaskInvocationParameters</code> </p> </li> <li> <p> <code>Priority</code> </p> </li> <li> <p> <code>MaxConcurrency</code> </p> </li> <li> <p> <code>MaxErrors</code> </p> </li> </ul> <note> <p>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 <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/maintenance-windows-targetless-tasks.html">Registering maintenance window tasks without targets</a> in the <i>Amazon Web Services Systems Manager User Guide</i>.</p> </note> <p>If the value for a parameter in <code>UpdateMaintenanceWindowTask</code> is null, then the corresponding field isn't modified. If you set <code>Replace</code> to true, then all fields required by the <a>RegisterTaskWithMaintenanceWindow</a> operation are required for this request. Optional fields that aren't specified are set to null.</p> <important> <p>When you update a maintenance window task that has options specified in <code>TaskInvocationParameters</code>, you must provide again all the <code>TaskInvocationParameters</code> values that you want to retain. The values you don't specify again are removed. For example, suppose that when you registered a Run Command task, you specified <code>TaskInvocationParameters</code> values for <code>Comment</code>, <code>NotificationConfig</code>, and <code>OutputS3BucketName</code>. If you update the maintenance window task and specify only a different <code>OutputS3BucketName</code> value, the values for <code>Comment</code> and <code>NotificationConfig</code> are removed.</p> </important>

    Args:
        window_id: <p>The maintenance window ID that contains the task to modify.</p>
        window_task_id: <p>The task ID to modify.</p>
        targets: <p>The targets (either managed nodes or tags) to modify. Managed nodes are specified using the format <code>Key=instanceids,Values=instanceID_1,instanceID_2</code>. Tags are specified using the format <code> Key=tag_name,Values=tag_value</code>. </p> <note> <p>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 <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/maintenance-windows-targetless-tasks.html">Registering maintenance window tasks without targets</a> in the <i>Amazon Web Services Systems Manager User Guide</i>.</p> </note>
        task_arn: <p>The task ARN to modify.</p>
        service_role_arn: <p>The Amazon Resource Name (ARN) of the IAM service role for Amazon Web Services Systems Manager to assume when running a maintenance window task. If you do not specify a service role ARN, Systems Manager uses a service-linked role in your account. If no appropriate service-linked role for Systems Manager exists in your account, it is created when you run <code>RegisterTaskWithMaintenanceWindow</code>.</p> <p>However, for an improved security posture, we strongly recommend creating a custom policy and custom service role for running your maintenance window tasks. The policy can be crafted to provide only the permissions needed for your particular maintenance window tasks. For more information, see <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-maintenance-permissions.html">Setting up Maintenance Windows</a> in the in the <i>Amazon Web Services Systems Manager User Guide</i>.</p>
        task_parameters: <p>The parameters to modify.</p> <note> <p> <code>TaskParameters</code> has been deprecated. To specify parameters to pass to a task when it runs, instead use the <code>Parameters</code> option in the <code>TaskInvocationParameters</code> structure. For information about how Systems Manager handles these options for the supported maintenance window task types, see <a>MaintenanceWindowTaskInvocationParameters</a>.</p> </note> <p>The map has the following format:</p> <p>Key: string, between 1 and 255 characters</p> <p>Value: an array of strings, each string is between 1 and 255 characters</p>
        task_invocation_parameters: <p>The parameters that the task should use during execution. Populate only the fields that match the task type. All other fields should be empty.</p> <important> <p>When you update a maintenance window task that has options specified in <code>TaskInvocationParameters</code>, you must provide again all the <code>TaskInvocationParameters</code> values that you want to retain. The values you don't specify again are removed. For example, suppose that when you registered a Run Command task, you specified <code>TaskInvocationParameters</code> values for <code>Comment</code>, <code>NotificationConfig</code>, and <code>OutputS3BucketName</code>. If you update the maintenance window task and specify only a different <code>OutputS3BucketName</code> value, the values for <code>Comment</code> and <code>NotificationConfig</code> are removed.</p> </important>
        priority: <p>The new task priority to specify. The lower the number, the higher the priority. Tasks that have the same priority are scheduled in parallel.</p>
        max_concurrency: <p>The new <code>MaxConcurrency</code> value you want to specify. <code>MaxConcurrency</code> is the number of targets that are allowed to run this task, in parallel.</p> <note> <p>Although this element is listed as "Required: No", a value can be omitted only when you are registering or updating a <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/maintenance-windows-targetless-tasks.html">targetless task</a> You must provide a value in all other cases.</p> <p>For maintenance window tasks without a target specified, you can't supply a value for this option. Instead, the system inserts a placeholder value of <code>1</code>. This value doesn't affect the running of your task.</p> </note>
        max_errors: <p>The new <code>MaxErrors</code> value to specify. <code>MaxErrors</code> is the maximum number of errors that are allowed before the task stops being scheduled.</p> <note> <p>Although this element is listed as "Required: No", a value can be omitted only when you are registering or updating a <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/maintenance-windows-targetless-tasks.html">targetless task</a> You must provide a value in all other cases.</p> <p>For maintenance window tasks without a target specified, you can't supply a value for this option. Instead, the system inserts a placeholder value of <code>1</code>. This value doesn't affect the running of your task.</p> </note>
        logging_info: <p>The new logging location in Amazon S3 to specify.</p> <note> <p> <code>LoggingInfo</code> has been deprecated. To specify an Amazon Simple Storage Service (Amazon S3) bucket to contain logs, instead use the <code>OutputS3BucketName</code> and <code>OutputS3KeyPrefix</code> options in the <code>TaskInvocationParameters</code> structure. For information about how Amazon Web Services Systems Manager handles these options for the supported maintenance window task types, see <a>MaintenanceWindowTaskInvocationParameters</a>.</p> </note>
        name: <p>The new task name to specify.</p>
        description: <p>The new task description to specify.</p>
        replace: <p>If True, then all fields that are required by the <a>RegisterTaskWithMaintenanceWindow</a> operation are also required for this API request. Optional fields that aren't specified are set to null.</p>
        cutoff_behavior: <p>Indicates whether tasks should continue to run after the cutoff time specified in the maintenance windows is reached. </p> <ul> <li> <p> <code>CONTINUE_TASK</code>: When the cutoff time is reached, any tasks that are running continue. The default value.</p> </li> <li> <p> <code>CANCEL_TASK</code>:</p> <ul> <li> <p>For Automation, Lambda, Step Functions tasks: When the cutoff time is reached, any task invocations that are already running continue, but no new task invocations are started.</p> </li> <li> <p>For Run Command tasks: When the cutoff time is reached, the system sends a <a>CancelCommand</a> operation that attempts to cancel the command associated with the task. However, there is no guarantee that the command will be terminated and the underlying process stopped.</p> </li> </ul> <p>The status for tasks that are not completed is <code>TIMED_OUT</code>.</p> </li> </ul>
        alarm_configuration: <p>The CloudWatch alarm you want to apply to your maintenance window task.</p>

    Raises:
        capo_ssm.errors.does_not_exist_exception.DoesNotExistException: <p>Error returned when the ID specified for a resource, such as a maintenance window or patch baseline, doesn't exist.</p> <p>For information about resource quotas in Amazon Web Services Systems Manager, see <a href="https://docs.aws.amazon.com/general/latest/gr/ssm.html#limits_ssm">Systems Manager service quotas</a> in the <i>Amazon Web Services General Reference</i>.</p>
        capo_ssm.errors.internal_server_error.InternalServerError: <p>An error occurred on the server side.</p>
        capo_ssm.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ssm.types.update_maintenance_window_task_request.UpdateMaintenanceWindowTaskRequest]",
    ) -> AsyncOperationResponse[
        "capo_ssm.types.update_maintenance_window_task_result.UpdateMaintenanceWindowTaskResult"
    ]:
        import capo_ssm._operations.amazon_ssm.update_maintenance_window_task

        (
            output,
            http_response,
        ) = await capo_ssm._operations.amazon_ssm.update_maintenance_window_task.async_update_maintenance_window_task(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_ssm.types.update_maintenance_window_task_request.UpdateMaintenanceWindowTaskRequest",
    ) -> dict[str, Any]:
        import capo_ssm.types.update_maintenance_window_task_request

        return (
            capo_ssm.types.update_maintenance_window_task_request.redact_sensitive(
                input_
            )
        )

    def _redact_output(
        output: "capo_ssm.types.update_maintenance_window_task_result.UpdateMaintenanceWindowTaskResult",
    ) -> dict[str, Any]:
        import capo_ssm.types.update_maintenance_window_task_result

        return (
            capo_ssm.types.update_maintenance_window_task_result.redact_sensitive(
                output
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "UpdateMaintenanceWindowTask",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_ssm.types.update_maintenance_window_task_request.UpdateMaintenanceWindowTaskRequest = {
        "window_id": window_id,
        "window_task_id": window_task_id,
    }
    if targets is not None:
        input_["targets"] = targets
    if task_arn is not None:
        input_["task_arn"] = task_arn
    if service_role_arn is not None:
        input_["service_role_arn"] = service_role_arn
    if task_parameters is not None:
        input_["task_parameters"] = task_parameters
    if task_invocation_parameters is not None:
        input_["task_invocation_parameters"] = task_invocation_parameters
    if priority is not None:
        input_["priority"] = priority
    if max_concurrency is not None:
        input_["max_concurrency"] = max_concurrency
    if max_errors is not None:
        input_["max_errors"] = max_errors
    if logging_info is not None:
        input_["logging_info"] = logging_info
    if name is not None:
        input_["name"] = name
    if description is not None:
        input_["description"] = description
    if replace is not None:
        input_["replace"] = replace
    if cutoff_behavior is not None:
        input_["cutoff_behavior"] = cutoff_behavior
    if alarm_configuration is not None:
        input_["alarm_configuration"] = alarm_configuration

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output