Skip to content

register_target_with_maintenance_window async

register_target_with_maintenance_window(
    window_id: MaintenanceWindowId,
    resource_type: MaintenanceWindowResourceType,
    targets: Targets,
    *,
    config_overrides: Optional[AsyncSSMClientConfig] = None,
    owner_information: Optional[OwnerInformation] = None,
    name: Optional[MaintenanceWindowName] = None,
    description: Optional[MaintenanceWindowDescription] = None,
    client_token: Optional[ClientToken] = None,
) -> RegisterTargetWithMaintenanceWindowResult

Registers a target with a maintenance window.

Parameters:

  • window_id (MaintenanceWindowId) –

    The ID of the maintenance window the target should be registered with.

  • resource_type (MaintenanceWindowResourceType) –

    The type of target being registered with the maintenance window.

  • targets (Targets) –

    The targets to register with the maintenance window. In other words, the managed nodes to run commands on when the maintenance window runs.

    If a single maintenance window task is registered with multiple targets, its task invocations occur sequentially and not in parallel. If your task must run on multiple targets at the same time, register a task for each target individually and assign each task the same priority level.

    You can specify targets using managed node IDs, resource group names, or tags that have been applied to managed nodes.

    Example 1: Specify managed node IDs

    Key=InstanceIds,Values=,,

    Example 2: Use tag key-pairs applied to managed nodes

    Key=tag:,Values=,

    Example 3: Use tag-keys applied to managed nodes

    Key=tag-key,Values=,

    Example 4: Use resource group names

    Key=resource-groups:Name,Values=

    Example 5: Use filters for resource group types

    Key=resource-groups:ResourceTypeFilters,Values=,

    For Key=resource-groups:ResourceTypeFilters, specify resource types in the following format

    Key=resource-groups:ResourceTypeFilters,Values=AWS::EC2::INSTANCE,AWS::EC2::VPC

    For more information about these examples formats, including the best use case for each one, see Examples: Register targets with a maintenance window in the Amazon Web Services Systems Manager User Guide.

  • owner_information (Optional[OwnerInformation], default: None ) –

    User-provided value that will be included in any Amazon CloudWatch Events events raised while running tasks for these targets in this maintenance window.

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

    An optional name for the target.

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

    An optional description for the target.

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

    User-provided idempotency token.

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.

  • 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/async_ssm.py
async def register_target_with_maintenance_window(
    self,
    window_id: "capo_ssm.types.maintenance_window_id.MaintenanceWindowId",
    resource_type: "capo_ssm.types.maintenance_window_resource_type.MaintenanceWindowResourceType",
    targets: "capo_ssm.types.targets.Targets",
    *,
    config_overrides: Optional[AsyncSSMClientConfig] = None,
    owner_information: Optional[
        "capo_ssm.types.owner_information.OwnerInformation"
    ] = None,
    name: Optional[
        "capo_ssm.types.maintenance_window_name.MaintenanceWindowName"
    ] = None,
    description: Optional[
        "capo_ssm.types.maintenance_window_description.MaintenanceWindowDescription"
    ] = None,
    client_token: Optional["capo_ssm.types.client_token.ClientToken"] = None,
) -> "capo_ssm.types.register_target_with_maintenance_window_result.RegisterTargetWithMaintenanceWindowResult":
    """<p>Registers a target with a maintenance window.</p>

    Args:
        window_id: <p>The ID of the maintenance window the target should be registered with.</p>
        resource_type: <p>The type of target being registered with the maintenance window.</p>
        targets: <p>The targets to register with the maintenance window. In other words, the managed nodes to run commands on when the maintenance window runs.</p> <note> <p>If a single maintenance window task is registered with multiple targets, its task invocations occur sequentially and not in parallel. If your task must run on multiple targets at the same time, register a task for each target individually and assign each task the same priority level.</p> </note> <p>You can specify targets using managed node IDs, resource group names, or tags that have been applied to managed nodes.</p> <p> <b>Example 1</b>: Specify managed node IDs</p> <p> <code>Key=InstanceIds,Values=<instance-id-1>,<instance-id-2>,<instance-id-3></code> </p> <p> <b>Example 2</b>: Use tag key-pairs applied to managed nodes</p> <p> <code>Key=tag:<my-tag-key>,Values=<my-tag-value-1>,<my-tag-value-2></code> </p> <p> <b>Example 3</b>: Use tag-keys applied to managed nodes</p> <p> <code>Key=tag-key,Values=<my-tag-key-1>,<my-tag-key-2></code> </p> <p> <b>Example 4</b>: Use resource group names</p> <p> <code>Key=resource-groups:Name,Values=<resource-group-name></code> </p> <p> <b>Example 5</b>: Use filters for resource group types</p> <p> <code>Key=resource-groups:ResourceTypeFilters,Values=<resource-type-1>,<resource-type-2></code> </p> <note> <p>For <code>Key=resource-groups:ResourceTypeFilters</code>, specify resource types in the following format</p> <p> <code>Key=resource-groups:ResourceTypeFilters,Values=AWS::EC2::INSTANCE,AWS::EC2::VPC</code> </p> </note> <p>For more information about these examples formats, including the best use case for each one, see <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/mw-cli-tutorial-targets-examples.html">Examples: Register targets with a maintenance window</a> in the <i>Amazon Web Services Systems Manager User Guide</i>.</p>
        owner_information: <p>User-provided value that will be included in any Amazon CloudWatch Events events raised while running tasks for these targets in this maintenance window.</p>
        name: <p>An optional name for the target.</p>
        description: <p>An optional description for the target.</p>
        client_token: <p>User-provided idempotency token.</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.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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ssm.types.register_target_with_maintenance_window_request.RegisterTargetWithMaintenanceWindowRequest]",
    ) -> AsyncOperationResponse[
        "capo_ssm.types.register_target_with_maintenance_window_result.RegisterTargetWithMaintenanceWindowResult"
    ]:
        import capo_ssm._operations.amazon_ssm.register_target_with_maintenance_window

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

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

        return capo_ssm.types.register_target_with_maintenance_window_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "RegisterTargetWithMaintenanceWindow", redact_input=_redact_input
        ),
    )
    input_: capo_ssm.types.register_target_with_maintenance_window_request.RegisterTargetWithMaintenanceWindowRequest = {
        "window_id": window_id,
        "resource_type": resource_type,
        "targets": targets,
    }
    if owner_information is not None:
        input_["owner_information"] = owner_information
    if name is not None:
        input_["name"] = name
    if description is not None:
        input_["description"] = description
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

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