AWS Guide
AWS Guide
to our walkthrough of
Setting up an AWS EC2 Instance
What is an EC2 Instance: An EC2 Instance is a virtual server in
Amazon’s Elastic Compute Cloud – EC2 – for running
applications on AWS infrastructure.
You need to sign up if you haven’t registered yet with AWS (and you can absolutely use
the free tier!) so head on over to https://aws.amazon.com/ec2/ to get started.
Here you can select the launch a virtual machine with EC2 option (you can see my
recently visited services EC2) When you click on that option it will navigate you to a list of
instances for step 1.
Now we have to go through the steps to finish the setup and to customize the instance. You
can follow along through each part. Since we are operating on the free tier we will be
operating with the services offered for that tier in Step 2: Choose an Instance Type:
We can now click on the next button (bottom right hand corner) we will move to
You can change the source to My IP so that it uses your IP and doesn’t allow all IP
addresses to access your instance.
Almost there!
Step 7: Review
Creation of the .pem file. This is important so please follow the following instructions before
launching the instance.
Create a new key pair which will download a file (make sure you download the key pair) as
it’s used to access the instance. Save this file and make sure it’s in a secure location as it will
needed each time to connect. You can create a folder so that it makes navigating to the
.pem file easier. In the walkthrough video I created a folder that I can navigate/CD to in the
future in the terminal so that the .pem when connecting.
I have a key pair created and named it awsec2-test. You can give it the name that you would
like but again save the file in a location that you can navigate to as you will need to be in
that location to access the instance.
Once you have the key pair downloaded, you can launch the instance. It will navigate
you to our next step.
In the bottom right hand corner click the blue button for View Instances. Here you will find the
instances that you set up (I have a few already and if this is your first you will only see one). For
example you can see instances running and terminated. When you are ready to connect to
your instance click on the box next to the name of the instance you have running and then
click on connect.
Again click on the selector for the name and it will open the option to connect. This will open
up a list of directions and instructions on how to connect.
Now we are ready to connect using the directions that AWS EC2 provides.
Since i’m using the Mac OS I will be operating in the terminal using SSH. If you are on Linux
you can use the SSH option and on Windows you can see the use of Putty (click the link in the
instructions for using PuTTY). Now we can open up a terminal and navigate to the location
that the .pem file is in. I stored my .pem in a folder, so I will CD there.
Once you are located in the directory of the .pem file you can use the instructions from
Connect to Your Instance. You can copy and paste in the terminal the example as it will work
in most cases. Yours will be different depending on the names and settings but copy the
example from your output message. Mine is:
Navigate back to the terminal and paste the command in and run it. You can authenticate it
if it has the message pop up for ECDSA but typing in yes. If you have any connectivity
issues, check the IP/security settings that you used.
If a public key error displays as in the video use the connect directions, specifically step 3:
3. Use the chmod 400 awsec2-test.pem command in the terminal and then re-run the ssh
connection.
With that you will be connected to the Ubuntu AWS EC2 Instance. Great Job!
Since we have our EC2 instance connected we have to treat it as a brand new OS to run
our linear regression and we will use Anaconda to install the required packages along with
Jupyter notebooks.
This will bring up the license information and options along with the installation path along
with prepending the installation path to the bash file.
You do not need to install VS code for the purpose of this tutorial. You can enter clear in the
terminal to remove the information so that you have a clean terminal.
localhost:8000
Navigate back to the terminal where you can find the token information (the first and
original terminal that we were operating from). Use the token information to log into your
Jupyter notebook.
Congratulations! You are now working in a Jupyter notebook and can run the
regression code below!
residual sum of squares between the observed responses in the dataset, and the responses
predicted by the linear approximation. Mathematically it solves a problem of the form:
http://scikit-learn.org/stable/modules/linear_model.html