Creating an EC2 instance of Jupyter Hub for Data Science Group Projects

Elizabeth Willard · February 7, 2024

While I like Google Colab, I have found it to be pretty limiting for data science projects.

Instead, I’ll be demonstrating how to create an EC2 instance to run The Littlest Jupyter Hub

Navigate to EC2 and select “Instances” -> “Create Instance”

Pasted image 20240207144936

The documentation for TLJH suggests that you select an Instance Type with at least 2GB of RAM like t3.small, but for my purposes, I am going to use T3.medium, since I could use just a little extra RAM.

Pasted image 20240207145215

Next, we go to Network settings to add two new rules, one for HTTP traffic and one for HTTPS traffic. Select “Edit” in the top right of the Network settings box to be shown this:

Pasted image 20240207145359

Now, generate a key pair

Pasted image 20240207145515 Pasted image 20240207145653

I’ll be using Putty so I selected .ppk

Select “add security group rule” at the bottom

Pasted image 20240207145721

You will need to add two: one for HTTP and HTTPS. Add 0.0.0.0/0 and ::/0 to the source fields for both.

Configure Storage as you need, I left it as default for now.

Pasted image 20240207145829

Finally, expand the drop-down menu “Advanced Details” You should see a series of options like so:

Pasted image 20240207145903

At the bottom of this menu, there will be a field called “user data”

Pasted image 20240207145934

#!/bin/bash
curl -L https://tljh.jupyter.org/bootstrap.py \
  | sudo python3 - \
    --admin [name of your choosing]

You will need to enter this bit of bash code to that field. You can now launch instance

Pasted image 20240207150011

It may take a few minutes in order to load, but you should see it running.

Pasted image 20240207150112

Once the instance has been started, you can use the public IPv4 address to access it. I had to use Google Chrome

Pasted image 20240207150512

Finally, you should be able to use the admin username and password you set in user-data here. If you didn’t set a password like me, then enter a password that you would like to use going forward.

Pasted image 20240207150617

You will be brought to your Jupyter Hub notebook! Congratulations.

If you use your public IP address and add /admin to the end, you can see admin-role specific settings.

Pasted image 20240207150700

You can create new users here and see what the server would look like from their perspective.

Twitter, Facebook