Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,57 +1,73 @@
---
sidebar_position: 11
author: Hailing Jiang
email: Hailing.Jiang@teradata.com
page_last_update: September 27th, 2022
author: Hailing Jiang, Janeth Graziani
email: Hailing.Jiang@teradata.com, developer.relations@teradata.com
page_last_update: July 9, 2026
description: Integrate Teradata Jupyter extensions with SageMaker notebook instance
keywords: [data warehouses, compute storage separation, teradata, vantage, cloud data platform, business intelligence, enterprise analytics, jupyter, teradatasql, ipython-sql, teradatasqlalchemy]
keywords: [data warehouses, compute storage separation, teradata, cloud data platform, business intelligence, enterprise analytics, jupyter, teradatasql, ipython-sql, teradatasqlalchemy]
---

import TrialDocsNote from '../_partials/teradata_trial.mdx'
import JupyterTrialsNote from '../_partials/jupyter_notebook_trials_note.mdx';

# Integrate Teradata Jupyter extensions with SageMaker notebook instance
# Integrate Teradata Jupyter extensions with SageMaker AI notebook instance


<JupyterTrialsNote />

### Overview
Teradata Jupyter extensions provide Teradata SQL kernel and several UI extensions to allow users to easily asccess and navigate Teradata database from Jupyter envioronment. This article describes how to integate our Jupyter extensions with SageMaker notebook instance.
Teradata Jupyter extensions provide Teradata SQL kernel and several UI extensions to allow users to easily access and navigate Teradata database from Jupyter environment. This article describes how to integrate our Jupyter extensions with SageMaker AI notebook instance.

### Prerequisites


* Access to a Teradata Vantage instance
* Access to a Teradata instance
<TrialDocsNote />
* AWS account
* AWS S3 bucket to store lifecycle configuration scripts and Teradata Jupyter extension package
* AWS account with permissions to create SageMaker notebook instances and IAM roles
* AWS S3 bucket to store the Teradata Jupyter extension package

### Integration

SageMaker supports customization of notebook instances using lifecycle configuration scripts. Below we will demo how to use lifecycle configuration scripts to install our Jupyter kernel and extensions in a notebook instance.
SageMaker AI supports customization of notebook instances using lifecycle configuration scripts. Below we will demo how to use lifecycle configuration scripts to install our Jupyter kernel and extensions in a notebook instance.

### Steps to integrate with notebook instance

1. Download Teradata Jupyter extensions package

Download Linux version from https://downloads.teradata.com/download/tools/vantage-modules-for-jupyter and upload it to an S3 bucket. This zipped package contains Teradata Jupyter kernel and extensions. Each extension has 2 files, the one with "_prebuilt" in the name is prebuilt extension which can be installed using PIP, the other one is source extension that needs to be installed using "jupyter labextension". It is recommended to use prebuilt extensions.
Download the Linux version from https://downloads.teradata.com/download/tools/vantage-modules-for-jupyter and upload the zip file to your S3 bucket. The package contains the Teradata Jupyter kernel and extensions as `.whl` files.

2. Create a lifecycle configuration for notebook instance
![Upload zip file to Amazon s3 bucket](../cloud-guides/images/integrate-teradata-jupyter-extensions-with-sagemaker/sagemaker.notebook.create.lifecycle.s3bucket.png)

2. **Grant SageMaker access to your S3 bucket**

The SageMaker execution role needs permission to read from your S3 bucket. In the AWS IAM console, find the execution role associated with your notebook instance (typically named `AmazonSageMaker-ExecutionRole-...`) and attach the `AmazonS3FullAccess` policy.

![Find execution role in IAM console ](../cloud-guides/images/integrate-teradata-jupyter-extensions-with-sagemaker/sagemaker.notebook.create.lifecycle.iam.png)

![Attach AmazonS3FullAccess to Execution Role](../cloud-guides/images/integrate-teradata-jupyter-extensions-with-sagemaker/sagemaker.Amazons3FullAccess.png)


3. Create a lifecycle configuration for notebook instance
![create a lifecycle configuration for notebook instance](../cloud-guides/images/integrate-teradata-jupyter-extensions-with-sagemaker/sagemaker.notebook.create.lifecycle.config.png)

Here are sample scripts that fetches the Teradata package from S3 bucket and installs Jupyter kernel and extensions. Note that on-create.sh creates a custom conda env that persists on notebook instance's EBS volume so that the installation will not get lost after notebook restarts. on-start.sh installs Teradata kernel and extensions to the custom conda env.

In the SageMaker console, navigate to **Lifecycle configurations** and create a new configuration. You will see two script tabs: **Create notebook** and **Start notebook**. Paste the scripts below into the corresponding tabs.



`on-create.sh` runs once when the notebook instance is first created. It installs a persistent conda environment on the EBS volume so the installation survives notebook restarts.


on-create.sh

``` bash , role="content-editable
#!/bin/bash

set -e

# This script installs a custom, persistent installation of conda on the Notebook Instance's EBS volume, and ensures
# that these custom environments are available as kernels in Jupyter.



sudo -u ec2-user -i <<'EOF'
unset SUDO_UID
# Install a separate conda installation via Miniconda
Expand All @@ -63,78 +79,83 @@ rm -rf "$WORKING_DIR/miniconda.sh"
# Create a custom conda environment
source "$WORKING_DIR/miniconda/bin/activate"
KERNEL_NAME="teradatasql"

PYTHON="3.8"
conda create --yes --name "$KERNEL_NAME" python="$PYTHON"
conda activate "$KERNEL_NAME"
pip install --quiet ipykernel

EOF
```

`on-start.sh` runs each time the notebook instance starts. It fetches the Teradata package from S3 and installs the Jupyter kernel and extensions. Replace `<your-s3-bucket>` with your bucket name and update the zip filename and `.whl` version numbers to match the version you downloaded.


on-start.sh

``` bash , role="content-editable"
#!/bin/bash

set -e

# This script installs Teradata Jupyter kernel and extensions.



sudo -u ec2-user -i <<'EOF'
unset SUDO_UID

WORKING_DIR=/home/ec2-user/SageMaker/custom-miniconda

source "$WORKING_DIR/miniconda/bin/activate" teradatasql

# fetch Teradata Jupyter extensions package from S3 and unzip it
mkdir -p "$WORKING_DIR/teradata"
aws s3 cp s3://sagemaker-teradata-bucket/teradatasqllinux_3.3.0-ec06172022.zip "$WORKING_DIR/teradata"
aws s3 cp s3://<your-s3-bucket>/teradatasqllinux_4.0.3-d03302026.zip "$WORKING_DIR/teradata"
cd "$WORKING_DIR/teradata"

unzip -o teradatasqllinux_3.3.0-ec06172022.zip

unzip -o teradatasqllinux_4.0.3-d03302026.zip

# install Teradata kernel
cp teradatakernel /home/ec2-user/anaconda3/condabin
source /home/ec2-user/anaconda3/bin/activate JupyterSystemEnv
jupyter kernelspec install --user ./teradatasql

# install Teradata Jupyter extensions
source /home/ec2-user/anaconda3/bin/activate JupyterSystemEnv

pip install teradata_connection_manager_prebuilt-3.3.0.tar.gz
pip install teradata_database_explorer_prebuilt-3.3.0.tar.gz
pip install teradata_preferences_prebuilt-3.3.0.tar.gz
pip install teradata_resultset_renderer_prebuilt-3.3.0.tar.gz
pip install teradata_sqlhighlighter_prebuilt-3.3.0.tar.gz

pip install teradata_connection_manager-4.0.3-py3-none-any.whl
pip install teradata_database_explorer-4.0.3-py3-none-any.whl
pip install teradata_preferences-4.0.3-py3-none-any.whl
pip install teradata_resultset_renderer-4.0.3-py3-none-any.whl
pip install teradata_sqlhighlighter-4.0.3-py3-none-any.whl

conda deactivate
EOF
```

3. Create a notebook instance. Please select 'Amazon Linux 2, Jupyter Lab3' for Platform identifier and select the lifecycle configuration created in step 2 for Lifecycle configuration.

![Create notebook instance](../cloud-guides/images/integrate-teradata-jupyter-extensions-with-sagemaker/sagemaker.notebook.create.notebook.instance.png)
4. **Create a notebook instance**

You might also need to add vpc, subnet and security group in 'Network' section to gain access to Teradata databases.
In the SageMaker console, create a new notebook instance. Select `Amazon Linux 2, Jupyter Lab 4` for the Platform identifier and select the lifecycle configuration created in step 3.

4. Wait until notebook instance Status turns 'InService', click 'Open JupyterLab' to open the notebook.
![Open notebook](../cloud-guides/images/integrate-teradata-jupyter-extensions-with-sagemaker/sagemaker.notebook.notebook.inservice.png)
Under **Permissions and encryption**, select the IAM execution role that has S3 access.

Under **Network**, select your VPC, subnet, and the default security group. Enable **Direct internet access** so the lifecycle scripts can reach S3 and install packages.

Access the demo notebooks to get usage tips
![Create notebook instance](../cloud-guides/images/integrate-teradata-jupyter-extensions-with-sagemaker/sagemaker.notebook.create.notebook.instance.png)

![Create notebook instance additional configs](../cloud-guides/images/integrate-teradata-jupyter-extensions-with-sagemaker/sagemaker.notebook.create.notebook.instance.additional.png)


5. **Open the notebook**

Wait until the notebook instance status turns **InService**, then click **Open JupyterLab**.

![Open notebook](../cloud-guides/images/integrate-teradata-jupyter-extensions-with-sagemaker/sagemaker.notebook.notebook.inservice.png)

Access the demo notebooks to get started. Navigate to `custom-miniconda/teradata/notebooks/sql/GettingStarted.ipynb`

![access demo notebooks](../cloud-guides/images/integrate-teradata-jupyter-extensions-with-sagemaker/sagemaker.notebook.start.png)


### Further reading
* [Teradata Jupyter Extensions Website](https://teradata.github.io/jupyterextensions)
* [Teradata Vantage™ Modules for Jupyter Installation Guide](https://docs.teradata.com/r/KQLs1kPXZ02rGWaS9Ktoww/root)
* [Teradata Modules for Jupyter Installation Guide](https://docs.teradata.com/r/KQLs1kPXZ02rGWaS9Ktoww/root)
* [Teradata® Package for Python User Guide](https://docs.teradata.com/r/1YKutX2ODdO9ppo_fnguTA/root)
* [Customize a Notebook Instance Using a Lifecycle Configuration Script](https://docs.aws.amazon.com/sagemaker/latest/dg/notebook-lifecycle-config.html)
* [amazon sagemaker notebook instance lifecycle config samples](https://github.com/aws-samples/amazon-sagemaker-notebook-instance-lifecycle-config-samples/blob/master/scripts/persistent-conda-ebs/on-create.sh)

import CommunityLinkPartial from '../_partials/community_link.mdx';

<CommunityLinkPartial />
* [amazon ai notebook instance lifecycle config samples](https://github.com/aws-samples/amazon-sagemaker-notebook-instance-lifecycle-config-samples/blob/master/scripts/persistent-conda-ebs/on-create.sh)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -268,5 +268,3 @@ The connection created must be referenced twice, once in the job configuration,

In this quick start, we learned how to ingest and catalog data from Teradata to Amazon S3 with AWS Glue Scripts.

### Further reading
* [Integrate Teradata with Google Cloud Data Catalog](./integrate-teradata-vantage-with-google-cloud-data-catalog.md)
Loading
Loading