Skip to content

create_maintenance_window

create_maintenance_window(
    name: MaintenanceWindowName,
    schedule: MaintenanceWindowSchedule,
    duration: MaintenanceWindowDurationHours,
    cutoff: MaintenanceWindowCutoff,
    allow_unassociated_targets: MaintenanceWindowAllowUnassociatedTargets,
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    description: Optional[MaintenanceWindowDescription] = None,
    start_date: Optional[MaintenanceWindowStringDateTime] = None,
    end_date: Optional[MaintenanceWindowStringDateTime] = None,
    schedule_timezone: Optional[MaintenanceWindowTimezone] = None,
    schedule_offset: Optional[MaintenanceWindowOffset] = None,
    client_token: Optional[ClientToken] = None,
    tags: Optional[TagList] = None,
) -> CreateMaintenanceWindowResult

Creates a new maintenance window.

The value you specify for Duration determines the specific end time for the maintenance window based on the time it begins. No maintenance window tasks are permitted to start after the resulting endtime minus the number of hours you specify for Cutoff. For example, if the maintenance window starts at 3 PM, the duration is three hours, and the value you specify for Cutoff is one hour, no maintenance window tasks can start after 5 PM.

Parameters:

  • name (MaintenanceWindowName) –

    The name of the maintenance window.

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

    An optional description for the maintenance window. We recommend specifying a description to help you organize your maintenance windows.

  • start_date (Optional[MaintenanceWindowStringDateTime], default: None ) –

    The date and time, in ISO-8601 Extended format, for when you want the maintenance window to become active. StartDate allows you to delay activation of the maintenance window until the specified future date.

    When using a rate schedule, if you provide a start date that occurs in the past, the current date and time are used as the start date.

  • end_date (Optional[MaintenanceWindowStringDateTime], default: None ) –

    The date and time, in ISO-8601 Extended format, for when you want the maintenance window to become inactive. EndDate allows you to set a date and time in the future when the maintenance window will no longer run.

  • schedule (MaintenanceWindowSchedule) –

    The schedule of the maintenance window in the form of a cron or rate expression.

  • schedule_timezone (Optional[MaintenanceWindowTimezone], default: None ) –

    The time zone that the scheduled maintenance window executions are based on, in Internet Assigned Numbers Authority (IANA) format. For example: "America/Los_Angeles", "UTC", or "Asia/Seoul". For more information, see the Time Zone Database on the IANA website.

  • schedule_offset (Optional[MaintenanceWindowOffset], default: None ) –

    The number of days to wait after the date and time specified by a cron expression before running the maintenance window.

    For example, the following cron expression schedules a maintenance window to run on the third Tuesday of every month at 11:30 PM.

    cron(30 23 ? * TUE#3 *)

    If the schedule offset is 2, the maintenance window won't run until two days later.

  • duration (MaintenanceWindowDurationHours) –

    The duration of the maintenance window in hours.

  • cutoff (MaintenanceWindowCutoff) –

    The number of hours before the end of the maintenance window that Amazon Web Services Systems Manager stops scheduling new tasks for execution.

  • allow_unassociated_targets (MaintenanceWindowAllowUnassociatedTargets) –

    Enables a maintenance window task to run on managed nodes, even if you haven't registered those nodes as targets. If enabled, then you must specify the unregistered managed nodes (by node ID) when you register a task with the maintenance window.

    If you don't enable this option, then you must specify previously-registered targets when you register a task with the maintenance window.

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

    User-provided idempotency token.

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

    Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways, such as by purpose, owner, or environment. For example, you might want to tag a maintenance window to identify the type of tasks it will run, the types of targets, and the environment it will run in. In this case, you could specify the following key-value pairs:

    • Key=TaskType,Value=AgentUpdate

    • Key=OS,Value=Windows

    • Key=Environment,Value=Production

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

Raises:

  • IdempotentParameterMismatch –

    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.

  • InternalServerError –

    An error occurred on the server side.

  • ResourceLimitExceededException –

    Error returned when the caller has exceeded the default resource quotas. For example, too many maintenance windows or patch baselines have been created.

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

  • UnknownServiceError –

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

Source code in docs_src/capo_ssm/_services/ssm.py
def create_maintenance_window(
    self,
    name: "capo_ssm.types.maintenance_window_name.MaintenanceWindowName",
    schedule: "capo_ssm.types.maintenance_window_schedule.MaintenanceWindowSchedule",
    duration: "capo_ssm.types.maintenance_window_duration_hours.MaintenanceWindowDurationHours",
    cutoff: "capo_ssm.types.maintenance_window_cutoff.MaintenanceWindowCutoff",
    allow_unassociated_targets: "capo_ssm.types.maintenance_window_allow_unassociated_targets.MaintenanceWindowAllowUnassociatedTargets",
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    description: Optional[
        "capo_ssm.types.maintenance_window_description.MaintenanceWindowDescription"
    ] = None,
    start_date: Optional[
        "capo_ssm.types.maintenance_window_string_date_time.MaintenanceWindowStringDateTime"
    ] = None,
    end_date: Optional[
        "capo_ssm.types.maintenance_window_string_date_time.MaintenanceWindowStringDateTime"
    ] = None,
    schedule_timezone: Optional[
        "capo_ssm.types.maintenance_window_timezone.MaintenanceWindowTimezone"
    ] = None,
    schedule_offset: Optional[
        "capo_ssm.types.maintenance_window_offset.MaintenanceWindowOffset"
    ] = None,
    client_token: Optional["capo_ssm.types.client_token.ClientToken"] = None,
    tags: Optional["capo_ssm.types.tag_list.TagList"] = None,
) -> (
    "capo_ssm.types.create_maintenance_window_result.CreateMaintenanceWindowResult"
):
    """<p>Creates a new maintenance window.</p> <note> <p>The value you specify for <code>Duration</code> determines the specific end time for the maintenance window based on the time it begins. No maintenance window tasks are permitted to start after the resulting endtime minus the number of hours you specify for <code>Cutoff</code>. For example, if the maintenance window starts at 3 PM, the duration is three hours, and the value you specify for <code>Cutoff</code> is one hour, no maintenance window tasks can start after 5 PM.</p> </note>

    Args:
        name: <p>The name of the maintenance window.</p>
        description: <p>An optional description for the maintenance window. We recommend specifying a description to help you organize your maintenance windows. </p>
        start_date: <p>The date and time, in ISO-8601 Extended format, for when you want the maintenance window to become active. <code>StartDate</code> allows you to delay activation of the maintenance window until the specified future date.</p> <note> <p>When using a rate schedule, if you provide a start date that occurs in the past, the current date and time are used as the start date. </p> </note>
        end_date: <p>The date and time, in ISO-8601 Extended format, for when you want the maintenance window to become inactive. <code>EndDate</code> allows you to set a date and time in the future when the maintenance window will no longer run.</p>
        schedule: <p>The schedule of the maintenance window in the form of a cron or rate expression.</p>
        schedule_timezone: <p>The time zone that the scheduled maintenance window executions are based on, in Internet Assigned Numbers Authority (IANA) format. For example: "America/Los_Angeles", "UTC", or "Asia/Seoul". For more information, see the <a href="https://www.iana.org/time-zones">Time Zone Database</a> on the IANA website.</p>
        schedule_offset: <p>The number of days to wait after the date and time specified by a cron expression before running the maintenance window.</p> <p>For example, the following cron expression schedules a maintenance window to run on the third Tuesday of every month at 11:30 PM.</p> <p> <code>cron(30 23 ? * TUE#3 *)</code> </p> <p>If the schedule offset is <code>2</code>, the maintenance window won't run until two days later.</p>
        duration: <p>The duration of the maintenance window in hours.</p>
        cutoff: <p>The number of hours before the end of the maintenance window that Amazon Web Services Systems Manager stops scheduling new tasks for execution.</p>
        allow_unassociated_targets: <p>Enables a maintenance window task to run on managed nodes, even if you haven't registered those nodes as targets. If enabled, then you must specify the unregistered managed nodes (by node ID) when you register a task with the maintenance window.</p> <p>If you don't enable this option, then you must specify previously-registered targets when you register a task with the maintenance window.</p>
        client_token: <p>User-provided idempotency token.</p>
        tags: <p>Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways, such as by purpose, owner, or environment. For example, you might want to tag a maintenance window to identify the type of tasks it will run, the types of targets, and the environment it will run in. In this case, you could specify the following key-value pairs:</p> <ul> <li> <p> <code>Key=TaskType,Value=AgentUpdate</code> </p> </li> <li> <p> <code>Key=OS,Value=Windows</code> </p> </li> <li> <p> <code>Key=Environment,Value=Production</code> </p> </li> </ul> <note> <p>To add tags to an existing maintenance window, use the <a>AddTagsToResource</a> operation.</p> </note>

    Raises:
        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.resource_limit_exceeded_exception.ResourceLimitExceededException: <p>Error returned when the caller has exceeded the default resource quotas. For example, too many maintenance windows or patch baselines have been created.</p> <p>For information about resource quotas in 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.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ssm.types.create_maintenance_window_request.CreateMaintenanceWindowRequest]",
    ) -> OperationResponse[
        "capo_ssm.types.create_maintenance_window_result.CreateMaintenanceWindowResult"
    ]:
        import capo_ssm._operations.amazon_ssm.create_maintenance_window

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

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

        return capo_ssm.types.create_maintenance_window_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateMaintenanceWindow", redact_input=_redact_input),
    )
    input_: capo_ssm.types.create_maintenance_window_request.CreateMaintenanceWindowRequest = {
        "name": name,
        "schedule": schedule,
        "duration": duration,
        "cutoff": cutoff,
        "allow_unassociated_targets": allow_unassociated_targets,
    }
    if description is not None:
        input_["description"] = description
    if start_date is not None:
        input_["start_date"] = start_date
    if end_date is not None:
        input_["end_date"] = end_date
    if schedule_timezone is not None:
        input_["schedule_timezone"] = schedule_timezone
    if schedule_offset is not None:
        input_["schedule_offset"] = schedule_offset
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if tags is not None:
        input_["tags"] = tags

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