Skip to content

update_notebook_instance

update_notebook_instance(
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    notebook_instance_name: Optional[NotebookInstanceName] = None,
    instance_type: Optional[InstanceType] = None,
    ip_address_type: Optional[IPAddressType] = None,
    platform_identifier: Optional[PlatformIdentifier] = None,
    role_arn: Optional[RoleArn] = None,
    lifecycle_config_name: Optional[NotebookInstanceLifecycleConfigName] = None,
    disassociate_lifecycle_config: Optional[
        DisassociateNotebookInstanceLifecycleConfig
    ] = None,
    volume_size_in_gb: Optional[NotebookInstanceVolumeSizeInGB] = None,
    default_code_repository: Optional[CodeRepositoryNameOrUrl] = None,
    additional_code_repositories: Optional[AdditionalCodeRepositoryNamesOrUrls] = None,
    accelerator_types: Optional[NotebookInstanceAcceleratorTypes] = None,
    disassociate_accelerator_types: Optional[
        DisassociateNotebookInstanceAcceleratorTypes
    ] = None,
    disassociate_default_code_repository: Optional[
        DisassociateDefaultCodeRepository
    ] = None,
    disassociate_additional_code_repositories: Optional[
        DisassociateAdditionalCodeRepositories
    ] = None,
    root_access: Optional[RootAccess] = None,
    instance_metadata_service_configuration: Optional[
        InstanceMetadataServiceConfiguration
    ] = None,
) -> UpdateNotebookInstanceOutput

Updates a notebook instance. NotebookInstance updates include upgrading or downgrading the ML compute instance used for your notebook instance to accommodate changes in your workload requirements.

This API can attach lifecycle configurations to notebook instances. Lifecycle configuration scripts execute with root access and the notebook instance's IAM execution role privileges. Principals with this permission and access to lifecycle configurations can execute code with the execution role's credentials. See Customize a Notebook Instance Using a Lifecycle Configuration Script for security best practices.

Parameters:

  • notebook_instance_name (Optional[NotebookInstanceName], default: None ) –

    The name of the notebook instance to update.

  • instance_type (Optional[InstanceType], default: None ) –

    The Amazon ML compute instance type.

  • ip_address_type (Optional[IPAddressType], default: None ) –

    The IP address type for the notebook instance. Specify ipv4 for IPv4-only connectivity or dualstack for both IPv4 and IPv6 connectivity. The notebook instance must be stopped before updating this setting. When you specify dualstack, the subnet must support IPv6 addressing.

  • platform_identifier (Optional[PlatformIdentifier], default: None ) –

    The platform identifier of the notebook instance runtime environment.

  • role_arn (Optional[RoleArn], default: None ) –

    The Amazon Resource Name (ARN) of the IAM role that SageMaker AI can assume to access the notebook instance. For more information, see SageMaker AI Roles.

    To be able to pass this role to SageMaker AI, the caller of this API must have the iam:PassRole permission.

  • lifecycle_config_name (Optional[NotebookInstanceLifecycleConfigName], default: None ) –

    The name of a lifecycle configuration to associate with the notebook instance. For information about lifestyle configurations, see Step 2.1: (Optional) Customize a Notebook Instance.

  • disassociate_lifecycle_config (Optional[DisassociateNotebookInstanceLifecycleConfig], default: None ) –

    Set to true to remove the notebook instance lifecycle configuration currently associated with the notebook instance. This operation is idempotent. If you specify a lifecycle configuration that is not associated with the notebook instance when you call this method, it does not throw an error.

  • volume_size_in_gb (Optional[NotebookInstanceVolumeSizeInGB], default: None ) –

    The size, in GB, of the ML storage volume to attach to the notebook instance. The default value is 5 GB. ML storage volumes are encrypted, so SageMaker AI can't determine the amount of available free space on the volume. Because of this, you can increase the volume size when you update a notebook instance, but you can't decrease the volume size. If you want to decrease the size of the ML storage volume in use, create a new notebook instance with the desired size.

  • default_code_repository (Optional[CodeRepositoryNameOrUrl], default: None ) –

    The Git repository to associate with the notebook instance as its default code repository. This can be either the name of a Git repository stored as a resource in your account, or the URL of a Git repository in Amazon Web Services CodeCommit or in any other Git repository. When you open a notebook instance, it opens in the directory that contains this repository. For more information, see Associating Git Repositories with SageMaker AI Notebook Instances.

  • additional_code_repositories (Optional[AdditionalCodeRepositoryNamesOrUrls], default: None ) –

    An array of up to three Git repositories to associate with the notebook instance. These can be either the names of Git repositories stored as resources in your account, or the URL of Git repositories in Amazon Web Services CodeCommit or in any other Git repository. These repositories are cloned at the same level as the default repository of your notebook instance. For more information, see Associating Git Repositories with SageMaker AI Notebook Instances.

  • accelerator_types (Optional[NotebookInstanceAcceleratorTypes], default: None ) –

    This parameter is no longer supported. Elastic Inference (EI) is no longer available.

    This parameter was used to specify a list of the EI instance types to associate with this notebook instance.

  • disassociate_accelerator_types (Optional[DisassociateNotebookInstanceAcceleratorTypes], default: None ) –

    This parameter is no longer supported. Elastic Inference (EI) is no longer available.

    This parameter was used to specify a list of the EI instance types to remove from this notebook instance.

  • disassociate_default_code_repository (Optional[DisassociateDefaultCodeRepository], default: None ) –

    The name or URL of the default Git repository to remove from this notebook instance. This operation is idempotent. If you specify a Git repository that is not associated with the notebook instance when you call this method, it does not throw an error.

  • disassociate_additional_code_repositories (Optional[DisassociateAdditionalCodeRepositories], default: None ) –

    A list of names or URLs of the default Git repositories to remove from this notebook instance. This operation is idempotent. If you specify a Git repository that is not associated with the notebook instance when you call this method, it does not throw an error.

  • root_access (Optional[RootAccess], default: None ) –

    Whether root access is enabled or disabled for users of the notebook instance. The default value is Enabled.

    If you set this to Disabled, users don't have root access on the notebook instance, but lifecycle configuration scripts still run with root permissions.

  • instance_metadata_service_configuration (Optional[InstanceMetadataServiceConfiguration], default: None ) –

    Information on the IMDS configuration of the notebook instance

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(
    self,
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    notebook_instance_name: Optional[
        "capo_sagemaker.types.notebook_instance_name.NotebookInstanceName"
    ] = None,
    instance_type: Optional[
        "capo_sagemaker.types.instance_type.InstanceType"
    ] = None,
    ip_address_type: Optional[
        "capo_sagemaker.types.ip_address_type.IPAddressType"
    ] = None,
    platform_identifier: Optional[
        "capo_sagemaker.types.platform_identifier.PlatformIdentifier"
    ] = None,
    role_arn: Optional["capo_sagemaker.types.role_arn.RoleArn"] = None,
    lifecycle_config_name: Optional[
        "capo_sagemaker.types.notebook_instance_lifecycle_config_name.NotebookInstanceLifecycleConfigName"
    ] = None,
    disassociate_lifecycle_config: Optional[
        "capo_sagemaker.types.disassociate_notebook_instance_lifecycle_config.DisassociateNotebookInstanceLifecycleConfig"
    ] = None,
    volume_size_in_gb: Optional[
        "capo_sagemaker.types.notebook_instance_volume_size_in_gb.NotebookInstanceVolumeSizeInGB"
    ] = None,
    default_code_repository: Optional[
        "capo_sagemaker.types.code_repository_name_or_url.CodeRepositoryNameOrUrl"
    ] = None,
    additional_code_repositories: Optional[
        "capo_sagemaker.types.additional_code_repository_names_or_urls.AdditionalCodeRepositoryNamesOrUrls"
    ] = None,
    accelerator_types: Optional[
        "capo_sagemaker.types.notebook_instance_accelerator_types.NotebookInstanceAcceleratorTypes"
    ] = None,
    disassociate_accelerator_types: Optional[
        "capo_sagemaker.types.disassociate_notebook_instance_accelerator_types.DisassociateNotebookInstanceAcceleratorTypes"
    ] = None,
    disassociate_default_code_repository: Optional[
        "capo_sagemaker.types.disassociate_default_code_repository.DisassociateDefaultCodeRepository"
    ] = None,
    disassociate_additional_code_repositories: Optional[
        "capo_sagemaker.types.disassociate_additional_code_repositories.DisassociateAdditionalCodeRepositories"
    ] = None,
    root_access: Optional["capo_sagemaker.types.root_access.RootAccess"] = None,
    instance_metadata_service_configuration: Optional[
        "capo_sagemaker.types.instance_metadata_service_configuration.InstanceMetadataServiceConfiguration"
    ] = None,
) -> "capo_sagemaker.types.update_notebook_instance_output.UpdateNotebookInstanceOutput":
    """<p>Updates a notebook instance. NotebookInstance updates include upgrading or downgrading the ML compute instance used for your notebook instance to accommodate changes in your workload requirements.</p> <note> <p>This API can attach lifecycle configurations to notebook instances. Lifecycle configuration scripts execute with root access and the notebook instance's IAM execution role privileges. Principals with this permission and access to lifecycle configurations can execute code with the execution role's credentials. 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_name: <p>The name of the notebook instance to update.</p>
        instance_type: <p>The Amazon ML compute instance type.</p>
        ip_address_type: <p>The IP address type for the notebook instance. Specify <code>ipv4</code> for IPv4-only connectivity or <code>dualstack</code> for both IPv4 and IPv6 connectivity. The notebook instance must be stopped before updating this setting. When you specify <code>dualstack</code>, the subnet must support IPv6 addressing.</p>
        platform_identifier: <p>The platform identifier of the notebook instance runtime environment.</p>
        role_arn: <p>The Amazon Resource Name (ARN) of the IAM role that SageMaker AI can assume to access the notebook instance. For more information, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html">SageMaker AI Roles</a>. </p> <note> <p>To be able to pass this role to SageMaker AI, the caller of this API must have the <code>iam:PassRole</code> permission.</p> </note>
        lifecycle_config_name: <p>The name of a lifecycle configuration to associate with the notebook instance. For information about lifestyle configurations, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/notebook-lifecycle-config.html">Step 2.1: (Optional) Customize a Notebook Instance</a>.</p>
        disassociate_lifecycle_config: <p>Set to <code>true</code> to remove the notebook instance lifecycle configuration currently associated with the notebook instance. This operation is idempotent. If you specify a lifecycle configuration that is not associated with the notebook instance when you call this method, it does not throw an error.</p>
        volume_size_in_gb: <p>The size, in GB, of the ML storage volume to attach to the notebook instance. The default value is 5 GB. ML storage volumes are encrypted, so SageMaker AI can't determine the amount of available free space on the volume. Because of this, you can increase the volume size when you update a notebook instance, but you can't decrease the volume size. If you want to decrease the size of the ML storage volume in use, create a new notebook instance with the desired size.</p>
        default_code_repository: <p>The Git repository to associate with the notebook instance as its default code repository. This can be either the name of a Git repository stored as a resource in your account, or the URL of a Git repository in <a href="https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html">Amazon Web Services CodeCommit</a> or in any other Git repository. When you open a notebook instance, it opens in the directory that contains this repository. For more information, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html">Associating Git Repositories with SageMaker AI Notebook Instances</a>.</p>
        additional_code_repositories: <p>An array of up to three Git repositories to associate with the notebook instance. These can be either the names of Git repositories stored as resources in your account, or the URL of Git repositories in <a href="https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html">Amazon Web Services CodeCommit</a> or in any other Git repository. These repositories are cloned at the same level as the default repository of your notebook instance. For more information, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html">Associating Git Repositories with SageMaker AI Notebook Instances</a>.</p>
        accelerator_types: <p>This parameter is no longer supported. Elastic Inference (EI) is no longer available.</p> <p>This parameter was used to specify a list of the EI instance types to associate with this notebook instance.</p>
        disassociate_accelerator_types: <p>This parameter is no longer supported. Elastic Inference (EI) is no longer available.</p> <p>This parameter was used to specify a list of the EI instance types to remove from this notebook instance.</p>
        disassociate_default_code_repository: <p>The name or URL of the default Git repository to remove from this notebook instance. This operation is idempotent. If you specify a Git repository that is not associated with the notebook instance when you call this method, it does not throw an error.</p>
        disassociate_additional_code_repositories: <p>A list of names or URLs of the default Git repositories to remove from this notebook instance. This operation is idempotent. If you specify a Git repository that is not associated with the notebook instance when you call this method, it does not throw an error.</p>
        root_access: <p>Whether root access is enabled or disabled for users of the notebook instance. The default value is <code>Enabled</code>.</p> <note> <p>If you set this to <code>Disabled</code>, users don't have root access on the notebook instance, but lifecycle configuration scripts still run with root permissions.</p> </note>
        instance_metadata_service_configuration: <p>Information on the IMDS configuration of the notebook instance</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_input.UpdateNotebookInstanceInput]",
    ) -> OperationResponse[
        "capo_sagemaker.types.update_notebook_instance_output.UpdateNotebookInstanceOutput"
    ]:
        import capo_sagemaker._operations.sage_maker.update_notebook_instance

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateNotebookInstance")
    )
    input_: capo_sagemaker.types.update_notebook_instance_input.UpdateNotebookInstanceInput = {}
    if notebook_instance_name is not None:
        input_["notebook_instance_name"] = notebook_instance_name
    if instance_type is not None:
        input_["instance_type"] = instance_type
    if ip_address_type is not None:
        input_["ip_address_type"] = ip_address_type
    if platform_identifier is not None:
        input_["platform_identifier"] = platform_identifier
    if role_arn is not None:
        input_["role_arn"] = role_arn
    if lifecycle_config_name is not None:
        input_["lifecycle_config_name"] = lifecycle_config_name
    if disassociate_lifecycle_config is not None:
        input_["disassociate_lifecycle_config"] = disassociate_lifecycle_config
    if volume_size_in_gb is not None:
        input_["volume_size_in_gb"] = volume_size_in_gb
    if default_code_repository is not None:
        input_["default_code_repository"] = default_code_repository
    if additional_code_repositories is not None:
        input_["additional_code_repositories"] = additional_code_repositories
    if accelerator_types is not None:
        input_["accelerator_types"] = accelerator_types
    if disassociate_accelerator_types is not None:
        input_["disassociate_accelerator_types"] = disassociate_accelerator_types
    if disassociate_default_code_repository is not None:
        input_["disassociate_default_code_repository"] = (
            disassociate_default_code_repository
        )
    if disassociate_additional_code_repositories is not None:
        input_["disassociate_additional_code_repositories"] = (
            disassociate_additional_code_repositories
        )
    if root_access is not None:
        input_["root_access"] = root_access
    if instance_metadata_service_configuration is not None:
        input_["instance_metadata_service_configuration"] = (
            instance_metadata_service_configuration
        )

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