Skip to content

update_notebook_instance_lifecycle_config

update_notebook_instance_lifecycle_config(
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    notebook_instance_lifecycle_config_name: Optional[
        NotebookInstanceLifecycleConfigName
    ] = None,
    on_create: Optional[NotebookInstanceLifecycleConfigList] = None,
    on_start: Optional[NotebookInstanceLifecycleConfigList] = None,
) -> UpdateNotebookInstanceLifecycleConfigOutput

Updates a notebook instance lifecycle configuration created with the CreateNotebookInstanceLifecycleConfig API.

Updates to lifecycle configurations affect all notebook instances using that configuration upon their next start. Lifecycle configuration scripts execute with root access and the notebook instance's IAM execution role privileges. Grant this permission only to trusted principals. See Customize a Notebook Instance Using a Lifecycle Configuration Script for security best practices.

Parameters:

Raises:

  • ResourceLimitExceeded –

    You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created.

  • UnknownServiceError –

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

Source code in docs_src/capo_sagemaker/_services/sage_maker.py
def update_notebook_instance_lifecycle_config(
    self,
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    notebook_instance_lifecycle_config_name: Optional[
        "capo_sagemaker.types.notebook_instance_lifecycle_config_name.NotebookInstanceLifecycleConfigName"
    ] = None,
    on_create: Optional[
        "capo_sagemaker.types.notebook_instance_lifecycle_config_list.NotebookInstanceLifecycleConfigList"
    ] = None,
    on_start: Optional[
        "capo_sagemaker.types.notebook_instance_lifecycle_config_list.NotebookInstanceLifecycleConfigList"
    ] = None,
) -> "capo_sagemaker.types.update_notebook_instance_lifecycle_config_output.UpdateNotebookInstanceLifecycleConfigOutput":
    """<p>Updates a notebook instance lifecycle configuration created with the <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateNotebookInstanceLifecycleConfig.html">CreateNotebookInstanceLifecycleConfig</a> API.</p> <note> <p>Updates to lifecycle configurations affect all notebook instances using that configuration upon their next start. Lifecycle configuration scripts execute with root access and the notebook instance's IAM execution role privileges. Grant this permission only to trusted principals. See <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/notebook-lifecycle-config.html">Customize a Notebook Instance Using a Lifecycle Configuration Script</a> for security best practices.</p> </note>

    Args:
        notebook_instance_lifecycle_config_name: <p>The name of the lifecycle configuration.</p>
        on_create: <p>The shell script that runs only once, when you create a notebook instance. The shell script must be a base64-encoded string.</p>
        on_start: <p>The shell script that runs every time you start a notebook instance, including when you create the notebook instance. The shell script must be a base64-encoded string.</p>

    Raises:
        capo_sagemaker.errors.resource_limit_exceeded.ResourceLimitExceeded: <p> You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created. </p>
        capo_sagemaker.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sagemaker.types.update_notebook_instance_lifecycle_config_input.UpdateNotebookInstanceLifecycleConfigInput]",
    ) -> OperationResponse[
        "capo_sagemaker.types.update_notebook_instance_lifecycle_config_output.UpdateNotebookInstanceLifecycleConfigOutput"
    ]:
        import capo_sagemaker._operations.sage_maker.update_notebook_instance_lifecycle_config

        output, http_response = (
            capo_sagemaker._operations.sage_maker.update_notebook_instance_lifecycle_config.update_notebook_instance_lifecycle_config(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateNotebookInstanceLifecycleConfig")
    )
    input_: capo_sagemaker.types.update_notebook_instance_lifecycle_config_input.UpdateNotebookInstanceLifecycleConfigInput = {}
    if notebook_instance_lifecycle_config_name is not None:
        input_["notebook_instance_lifecycle_config_name"] = (
            notebook_instance_lifecycle_config_name
        )
    if on_create is not None:
        input_["on_create"] = on_create
    if on_start is not None:
        input_["on_start"] = on_start

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