Skip to main content

notebook_instances

Creates, updates, deletes, gets or lists a notebook_instances resource.

Overview

Namenotebook_instances
TypeResource
Idaws.sagemaker.notebook_instances

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
accelerator_typesarrayThis 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 associated with this notebook instance.
additional_code_repositoriesarrayAn array of up to three Git repositories associated 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.
creation_timestring (date-time)A timestamp. Use this parameter to return the time when the notebook instance was created
default_code_repositorystringThe Git repository associated 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. (pattern: <code>https:​//([^/]+)/?(.)$|^[a-zA-Z0-9](-[a-zA-Z0-9])*</code>)
direct_internet_accessstringDescribes whether SageMaker AI provides internet access to the notebook instance. If this value is set to Disabled, the notebook instance does not have internet access, and cannot connect to SageMaker AI training and endpoint services. For more information, see Notebook Instances Are Internet-Enabled by Default. (Enabled, Disabled)
failure_reasonstringIf status is Failed, the reason it failed.
instance_metadata_service_configurationobjectInformation on the IMDS configuration of the notebook instance
instance_typestringThe type of ML compute instance running on the notebook instance. (ml.t2.medium, ml.t2.large, ml.t2.xlarge, ml.t2.2xlarge, ml.t3.medium, ml.t3.large, ml.t3.xlarge, ml.t3.2xlarge, ml.m4.xlarge, ml.m4.2xlarge, ml.m4.4xlarge, ml.m4.10xlarge, ml.m4.16xlarge, ml.m5.xlarge, ml.m5.2xlarge, ml.m5.4xlarge, ml.m5.12xlarge, ml.m5.24xlarge, ml.m5d.large, ml.m5d.xlarge, ml.m5d.2xlarge, ml.m5d.4xlarge, ml.m5d.8xlarge, ml.m5d.12xlarge, ml.m5d.16xlarge, ml.m5d.24xlarge, ml.c4.xlarge, ml.c4.2xlarge, ml.c4.4xlarge, ml.c4.8xlarge, ml.c5.xlarge, ml.c5.2xlarge, ml.c5.4xlarge, ml.c5.9xlarge, ml.c5.18xlarge, ml.c5d.xlarge, ml.c5d.2xlarge, ml.c5d.4xlarge, ml.c5d.9xlarge, ml.c5d.18xlarge, ml.p2.xlarge, ml.p2.8xlarge, ml.p2.16xlarge, ml.p3.2xlarge, ml.p3.8xlarge, ml.p3.16xlarge, ml.p3dn.24xlarge, ml.g4dn.xlarge, ml.g4dn.2xlarge, ml.g4dn.4xlarge, ml.g4dn.8xlarge, ml.g4dn.12xlarge, ml.g4dn.16xlarge, ml.r5.large, ml.r5.xlarge, ml.r5.2xlarge, ml.r5.4xlarge, ml.r5.8xlarge, ml.r5.12xlarge, ml.r5.16xlarge, ml.r5.24xlarge, ml.g5.xlarge, ml.g5.2xlarge, ml.g5.4xlarge, ml.g5.8xlarge, ml.g5.16xlarge, ml.g5.12xlarge, ml.g5.24xlarge, ml.g5.48xlarge, ml.inf1.xlarge, ml.inf1.2xlarge, ml.inf1.6xlarge, ml.inf1.24xlarge, ml.trn1.2xlarge, ml.trn1.32xlarge, ml.trn1n.32xlarge, ml.inf2.xlarge, ml.inf2.8xlarge, ml.inf2.24xlarge, ml.inf2.48xlarge, ml.p4d.24xlarge, ml.p4de.24xlarge, ml.p5.48xlarge, ml.p6-b200.48xlarge, ml.m6i.large, ml.m6i.xlarge, ml.m6i.2xlarge, ml.m6i.4xlarge, ml.m6i.8xlarge, ml.m6i.12xlarge, ml.m6i.16xlarge, ml.m6i.24xlarge, ml.m6i.32xlarge, ml.m7i.large, ml.m7i.xlarge, ml.m7i.2xlarge, ml.m7i.4xlarge, ml.m7i.8xlarge, ml.m7i.12xlarge, ml.m7i.16xlarge, ml.m7i.24xlarge, ml.m7i.48xlarge, ml.c6i.large, ml.c6i.xlarge, ml.c6i.2xlarge, ml.c6i.4xlarge, ml.c6i.8xlarge, ml.c6i.12xlarge, ml.c6i.16xlarge, ml.c6i.24xlarge, ml.c6i.32xlarge, ml.c7i.large, ml.c7i.xlarge, ml.c7i.2xlarge, ml.c7i.4xlarge, ml.c7i.8xlarge, ml.c7i.12xlarge, ml.c7i.16xlarge, ml.c7i.24xlarge, ml.c7i.48xlarge, ml.r6i.large, ml.r6i.xlarge, ml.r6i.2xlarge, ml.r6i.4xlarge, ml.r6i.8xlarge, ml.r6i.12xlarge, ml.r6i.16xlarge, ml.r6i.24xlarge, ml.r6i.32xlarge, ml.r7i.large, ml.r7i.xlarge, ml.r7i.2xlarge, ml.r7i.4xlarge, ml.r7i.8xlarge, ml.r7i.12xlarge, ml.r7i.16xlarge, ml.r7i.24xlarge, ml.r7i.48xlarge, ml.m6id.large, ml.m6id.xlarge, ml.m6id.2xlarge, ml.m6id.4xlarge, ml.m6id.8xlarge, ml.m6id.12xlarge, ml.m6id.16xlarge, ml.m6id.24xlarge, ml.m6id.32xlarge, ml.c6id.large, ml.c6id.xlarge, ml.c6id.2xlarge, ml.c6id.4xlarge, ml.c6id.8xlarge, ml.c6id.12xlarge, ml.c6id.16xlarge, ml.c6id.24xlarge, ml.c6id.32xlarge, ml.r6id.large, ml.r6id.xlarge, ml.r6id.2xlarge, ml.r6id.4xlarge, ml.r6id.8xlarge, ml.r6id.12xlarge, ml.r6id.16xlarge, ml.r6id.24xlarge, ml.r6id.32xlarge, ml.g6.xlarge, ml.g6.2xlarge, ml.g6.4xlarge, ml.g6.8xlarge, ml.g6.12xlarge, ml.g6.16xlarge, ml.g6.24xlarge, ml.g6.48xlarge, ml.g7e.2xlarge, ml.g7e.4xlarge, ml.g7e.8xlarge, ml.g7e.12xlarge, ml.g7e.24xlarge, ml.g7e.48xlarge, ml.p5.4xlarge, ml.p5en.48xlarge, ml.g6e.xlarge, ml.g6e.2xlarge, ml.g6e.4xlarge, ml.g6e.8xlarge, ml.g6e.12xlarge, ml.g6e.16xlarge, ml.g6e.24xlarge, ml.g6e.48xlarge)
ip_address_typestringThe IP address type configured for the notebook instance. Returns ipv4 for IPv4-only connectivity or dualstack for both IPv4 and IPv6 connectivity. (ipv4, dualstack)
kms_key_idstringThe Amazon Web Services KMS key ID SageMaker AI uses to encrypt data when storing it on the ML storage volume attached to the instance. (pattern: <code>[a-zA-Z0-9:/_-]*</code>)
last_modified_timestring (date-time)A timestamp. Use this parameter to retrieve the time when the notebook instance was last modified.
network_interface_idstringThe network interface IDs that SageMaker AI created at the time of creating the instance.
notebook_instance_arnstringThe Amazon Resource Name (ARN) of the notebook instance.
notebook_instance_lifecycle_config_namestringReturns the name of a notebook instance lifecycle configuration. For information about notebook instance lifestyle configurations, see Step 2.1: (Optional) Customize a Notebook Instance (pattern: <code>[a-zA-Z0-9](-[a-zA-Z0-9])</code>)
notebook_instance_namestringThe name of the SageMaker AI notebook instance. (pattern: <code>[a-zA-Z0-9](-[a-zA-Z0-9])</code>)
notebook_instance_statusstringThe status of the notebook instance. (Pending, InService, Stopping, Stopped, Failed, Deleting, Updating, PendingMaintenance, InMaintenance)
platform_identifierstringThe platform identifier of the notebook instance runtime environment. (pattern: <code>(notebook-al1-v1|notebook-al2-v1|notebook-al2-v2|notebook-al2-v3|notebook-al2023-v1)</code>)
role_arnstringThe Amazon Resource Name (ARN) of the IAM role associated with the instance. (pattern: <code>arn:aws[a-z-]*:iam::\d{12}:role/?[a-zA-Z_0-9+=,.@-_/]+</code>)
root_accessstringWhether root access is enabled or disabled for users of the notebook instance. Lifecycle configurations need root access to be able to set up a notebook instance. Because of this, lifecycle configurations associated with a notebook instance always run with root access even if you disable root access for users. (Enabled, Disabled)
security_groupsarrayThe IDs of the VPC security groups.
subnet_idstringThe ID of the VPC subnet. (pattern: <code>[-0-9a-zA-Z]+</code>)
urlstringThe URL that you use to connect to the Jupyter notebook that is running in your notebook instance.
volume_size_in_gbintegerThe size, in GB, of the ML storage volume attached to the notebook instance.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_notebook_instanceselectregionReturns information about a notebook instance.
list_notebook_instancesselectregionReturns a list of the SageMaker AI notebook instances in the requester's account in an Amazon Web Services Region.
create_notebook_instanceinsertregion, NotebookInstanceName, InstanceType, RoleArnCreates an SageMaker AI notebook instance. A notebook instance is a machine learning (ML) compute instance running on a Jupyter notebook. In a CreateNotebookInstance request, specify the type of ML compute instance that you want to run. SageMaker AI launches the instance, installs common libraries that you can use to explore datasets for model training, and attaches an ML storage volume to the notebook instance. SageMaker AI also provides a set of example notebooks. Each notebook demonstrates how to use SageMaker AI with a specific algorithm or with a machine learning framework. After receiving the request, SageMaker AI does the following: Creates a network interface in the SageMaker AI VPC. (Option) If you specified SubnetId, SageMaker AI creates a network interface in your own VPC, which is inferred from the subnet ID that you provide in the input. When creating this network interface, SageMaker AI attaches the security group that you specified in the request to the network interface that it creates in your VPC. Launches an EC2 instance of the type specified in the request in the SageMaker AI VPC. If you specified SubnetId of your VPC, SageMaker AI specifies both network interfaces when launching this instance. This enables inbound traffic from your own VPC to the notebook instance, assuming that the security groups allow it. After creating the notebook instance, SageMaker AI returns its Amazon Resource Name (ARN). You can't change the name of a notebook instance after you create it. After SageMaker AI creates the notebook instance, you can connect to the Jupyter server and work in Jupyter notebooks. For example, you can write code to explore a dataset that you can use for model training, train a model, host models by creating SageMaker AI endpoints, and validate hosted models. For more information, see How It Works.
create_presigned_notebook_instance_urlinsertregion, NotebookInstanceNameReturns a URL that you can use to connect to the Jupyter server from a notebook instance. In the SageMaker AI console, when you choose Open next to a notebook instance, SageMaker AI opens a new tab showing the Jupyter server home page from the notebook instance. The console uses this API to get the URL and show the page. The IAM role or user used to call this API defines the permissions to access the notebook instance. Once the presigned URL is created, no additional permission is required to access this URL. IAM authorization policies for this API are also enforced for every HTTP request and WebSocket frame that attempts to connect to the notebook instance. You can restrict access to this API and to the URL that it returns to a list of IP addresses that you specify. Use the NotIpAddress condition operator and the aws:SourceIP condition context key to specify the list of IP addresses that you want to have access to the notebook instance. For more information, see Limit Access to a Notebook Instance by IP Address. The URL that you get from a call to CreatePresignedNotebookInstanceUrl is valid only for 5 minutes. If you try to use the URL after the 5-minute limit expires, you are directed to the Amazon Web Services console sign-in page.
update_notebook_instanceupdateregion, NotebookInstanceNameUpdates 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.
delete_notebook_instancedeleteregionDeletes an SageMaker AI notebook instance. Before you can delete a notebook instance, you must call the StopNotebookInstance API. When you delete a notebook instance, you lose all of your data. SageMaker AI removes the ML compute instance, and deletes the ML storage volume and the network interface associated with the notebook instance.
start_notebook_instanceexecregion, NotebookInstanceNameLaunches an ML compute instance with the latest version of the libraries and attaches your ML storage volume. After configuring the notebook instance, SageMaker AI sets the notebook instance status to InService. A notebook instance's status must be InService before you can connect to your Jupyter notebook.
stop_notebook_instanceexecregion, NotebookInstanceNameTerminates the ML compute instance. Before terminating the instance, SageMaker AI disconnects the ML storage volume from it. SageMaker AI preserves the ML storage volume. SageMaker AI stops charging you for the ML compute instance when you call StopNotebookInstance. To access data on the ML storage volume for a notebook instance that has been terminated, call the StartNotebookInstance API. StartNotebookInstance launches another ML compute instance, configures it, and attaches the preserved ML storage volume so you can continue your work.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
regionstringAWS region (default: us-east-1)

SELECT examples

Returns information about a notebook instance.

SELECT
accelerator_types,
additional_code_repositories,
creation_time,
default_code_repository,
direct_internet_access,
failure_reason,
instance_metadata_service_configuration,
instance_type,
ip_address_type,
kms_key_id,
last_modified_time,
network_interface_id,
notebook_instance_arn,
notebook_instance_lifecycle_config_name,
notebook_instance_name,
notebook_instance_status,
platform_identifier,
role_arn,
root_access,
security_groups,
subnet_id,
url,
volume_size_in_gb
FROM aws.sagemaker.notebook_instances
WHERE region = '{{ region }}' -- required
;

INSERT examples

Creates an SageMaker AI notebook instance. A notebook instance is a machine learning (ML) compute instance running on a Jupyter notebook. In a CreateNotebookInstance request, specify the type of ML compute instance that you want to run. SageMaker AI launches the instance, installs common libraries that you can use to explore datasets for model training, and attaches an ML storage volume to the notebook instance. SageMaker AI also provides a set of example notebooks. Each notebook demonstrates how to use SageMaker AI with a specific algorithm or with a machine learning framework. After receiving the request, SageMaker AI does the following: Creates a network interface in the SageMaker AI VPC. (Option) If you specified SubnetId, SageMaker AI creates a network interface in your own VPC, which is inferred from the subnet ID that you provide in the input. When creating this network interface, SageMaker AI attaches the security group that you specified in the request to the network interface that it creates in your VPC. Launches an EC2 instance of the type specified in the request in the SageMaker AI VPC. If you specified SubnetId of your VPC, SageMaker AI specifies both network interfaces when launching this instance. This enables inbound traffic from your own VPC to the notebook instance, assuming that the security groups allow it. After creating the notebook instance, SageMaker AI returns its Amazon Resource Name (ARN). You can't change the name of a notebook instance after you create it. After SageMaker AI creates the notebook instance, you can connect to the Jupyter server and work in Jupyter notebooks. For example, you can write code to explore a dataset that you can use for model training, train a model, host models by creating SageMaker AI endpoints, and validate hosted models. For more information, see How It Works.

INSERT INTO aws.sagemaker.notebook_instances (
NotebookInstanceName,
InstanceType,
SubnetId,
SecurityGroupIds,
IpAddressType,
RoleArn,
KmsKeyId,
Tags,
LifecycleConfigName,
DirectInternetAccess,
VolumeSizeInGB,
AcceleratorTypes,
DefaultCodeRepository,
AdditionalCodeRepositories,
RootAccess,
PlatformIdentifier,
InstanceMetadataServiceConfiguration,
region
)
SELECT
'{{ NotebookInstanceName }}' /* required */,
'{{ InstanceType }}' /* required */,
'{{ SubnetId }}',
'{{ SecurityGroupIds }}',
'{{ IpAddressType }}',
'{{ RoleArn }}' /* required */,
'{{ KmsKeyId }}',
'{{ Tags }}',
'{{ LifecycleConfigName }}',
'{{ DirectInternetAccess }}',
{{ VolumeSizeInGB }},
'{{ AcceleratorTypes }}',
'{{ DefaultCodeRepository }}',
'{{ AdditionalCodeRepositories }}',
'{{ RootAccess }}',
'{{ PlatformIdentifier }}',
'{{ InstanceMetadataServiceConfiguration }}',
'{{ region }}'
RETURNING
notebook_instance_arn
;

UPDATE examples

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.

UPDATE aws.sagemaker.notebook_instances
SET
NotebookInstanceName = '{{ NotebookInstanceName }}',
InstanceType = '{{ InstanceType }}',
IpAddressType = '{{ IpAddressType }}',
PlatformIdentifier = '{{ PlatformIdentifier }}',
RoleArn = '{{ RoleArn }}',
LifecycleConfigName = '{{ LifecycleConfigName }}',
DisassociateLifecycleConfig = {{ DisassociateLifecycleConfig }},
VolumeSizeInGB = {{ VolumeSizeInGB }},
DefaultCodeRepository = '{{ DefaultCodeRepository }}',
AdditionalCodeRepositories = '{{ AdditionalCodeRepositories }}',
AcceleratorTypes = '{{ AcceleratorTypes }}',
DisassociateAcceleratorTypes = {{ DisassociateAcceleratorTypes }},
DisassociateDefaultCodeRepository = {{ DisassociateDefaultCodeRepository }},
DisassociateAdditionalCodeRepositories = {{ DisassociateAdditionalCodeRepositories }},
RootAccess = '{{ RootAccess }}',
InstanceMetadataServiceConfiguration = '{{ InstanceMetadataServiceConfiguration }}'
WHERE
region = '{{ region }}' --required
AND NotebookInstanceName = '{{ NotebookInstanceName }}' --required;

DELETE examples

Deletes an SageMaker AI notebook instance. Before you can delete a notebook instance, you must call the StopNotebookInstance API. When you delete a notebook instance, you lose all of your data. SageMaker AI removes the ML compute instance, and deletes the ML storage volume and the network interface associated with the notebook instance.

DELETE FROM aws.sagemaker.notebook_instances
WHERE region = '{{ region }}' --required
;

Lifecycle Methods

Launches an ML compute instance with the latest version of the libraries and attaches your ML storage volume. After configuring the notebook instance, SageMaker AI sets the notebook instance status to InService. A notebook instance's status must be InService before you can connect to your Jupyter notebook.

EXEC aws.sagemaker.notebook_instances.start_notebook_instance
@region='{{ region }}' --required
@@json=
'{
"NotebookInstanceName": "{{ NotebookInstanceName }}"
}'
;