Create EC2 Instance Containing Jupyter Server
Create EC2 Instance Containing Jupyter Server
In this tutorial you will create an EC2 instance with Jupyter notebook server from Ubuntu AMI.
1. Login to the AWS console. Go to EC2 and create an EC2 instance using
Ubuntu server 20.04 AMI.
a. Type EC2 in the search bar of AWS console. Click on EC2 in the search results. This will
open the EC2 console.
c. On the Step1: Choose an Amazon Machine Image (AMI) page scroll down and select
Ubuntu Server 20.04 LTS.
d. On the next page keep default t2.micro instance type. Click Next: Configure instance
details.
g. Once the EC2 instance is created, use Putty to connect to this EC2 Instance.
a. Once you login to the EC2 instance, enter following command first in the putty console..
sudo apt update -y
b. Once the above command completes then issue the following command.
sudo apt upgrade -y
c. Now install python pip and the python dev package using following command.
sudo apt install python3-pip python3-dev -y
f. Create a directory where you will create the python virtual environment.
mkdir projects
cd Projects
This will create a directory inside projects directory by the name specified. (E.g. here the
directory projects_env is created). This directory contains the python and its required
libraries.
h. Activate the virtual environment by giving following command.
source projects_env/bin/activate
j. To test if the jupyter server is installed correctly and it is working properly issue the
following command.
jupyter notebook
if you get the output as follows then it means the jupter server is installed properly.
Now stop this jupyter server by pressing Ctrl+C buttons. Type y to shutdown the server.
Close the Putty connection to the EC2 server.
3. Use tunnel option in Putty to access the Jupyter notebook on local computer
port.
a. Open Putty. In the hostname field type public IPv4 address or Public IPv4 DNS name of
the EC2 instance.
b. Expand SSH section. In Auth field select the .ppk key to access the above EC2 instance.
In the Source field type a port number greater than 5000 (this is just to avoid conflicts with
other services. It is not a rule. You can type any port number above 1024). This is the port
that Putty will open on your local laptop and will make the Jupyter notebook available.
In the Destination field type localhost:8888. This the URL on which the Jupyter server runs.
The port 8888 is the port used by the Jupyter server on the EC2 instance.
Now click Add button. The configuration will look as shown below.
cd projects
source projects_env/bin/activate
jupyter notebook
e. Now open a new tab in the local browser. In the tab type http://localhost:8000 . The
jupyter notebook web page will be displayed.
To login copy the number displayed in front of token= in the Putty screen. Paste in the
Password or Token field in the browser. Click Login.
f. Close this window. Press Ctrl+C in the Putty terminal to stop jupyter server. Close the
Putty connection.
Clean Up
Make sure you delete all the resources created for this practical.
1. Go to Instances. Select your instance . Select Instance State and Click Terminate.