Personality Prediction System End to End Deployment on AWS

Jino Rohit
4 min readJun 7, 2022

In this tutorial, we will be looking at how to get our predictor system up and running on the AWS EC2 service.

This is actually a follow up on part-1 of the tutorial series where we deployed the system on Flask . I would recommend you to first give that a read — https://jinooo.medium.com/personality-prediction-system-end-to-end-deployment-on-flask-10d1af9faf78

Amazon EC2

This is an Amazon web service that provides scalable compute instances over cloud. Using this you can launch as many virtual servers as you want, rescale them, configure CPU, memory, storage, and networking capacity. This also comes with a very secure security system which uses the key-pair information which we will look into later.

You can read plenty on this here — https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html

If you’re a first time user, this might be a bit overwhelming , but don’t worry I will walk you through each and every step

Creating an instance

Search for EC2 on the services panel and and search for ubuntu instances

In the instance type, the free tier instance t2. micro should be enough.

Next directly skip to the Configure Security Group where you will have to add your own rule. To make sure we can access the instance from anywhere you have to change the Type to All traffic and Source to Anywhere

Now you can skip onto the review and launch where you will be asked to create or use an existing key pair. This key pair is very important as you will be able to connect to your EC2 instance using this key pair. Let’s create a new one and call it personality.

On clicking download, you should be able be able to see a personality.pem file downloaded to your computer. Go ahead and place it in your project folder.

You should be able to see your instance running in a while

Conversion of key format

The key format that you currently have is in .pem but EC2 needs it in the .ppk extension. To make that conversion, you will need a software called PuttyGen. You can download it from here — https://www.puttygen.com/

Once you have launched it, click on the Load Existing Private Key and find your .pem file. Now click on Save Private Key and give it a name. This now gets converted to the .ppk format.

File Transfer

Now we have our project folder files that we need to move the ubuntu instance that we created earlier. For this , we need an ssh client. Since I’m on windows , I will be making use of the git bash terminal.

To get connected to the EC2 instance, go to your aws terminal, click on the instance you just launched and click on Connect to Instance — SSH Client. You should be able to see something like this

Nagivate to the project folder where you have your key pair and run these commands on your git bash. On running those, you should be able to connect to the instance

Now to transfer the files, you have to open another terminal and navigate to where the project files are and run this —

scp -i “personality.pem” file_name ubuntu@ec2–3–6–41–71.ap-south-1.compute.amazonaws.com:directory

Here’s an example

Once you are done transferring all the files, you should be able to ls and see all the files.

Now run the following commands in sequence

sudo apt-get update # to get the latest updates

sudo apt-get install python3-pip #this installs pip with which we will be installing all our packages

pip3 install -r requirements.txt #install all the packages necessary to run the program

Finally python3 app.py and you should be able to see your server load up.

Now if you go back to your instance details on AWS console, we can use the Public IPv4 address or the Public IPv4 DNS to run the program on the browser.

Public IPv4 address:8080 / Public IPv4 DNS:8080

Tadaaaa.

You should be able to make your predictions now along with your friends worldwide :)

I hope this was a fun little project and I’m happy to help with any doubts.

Find me at — https://www.linkedin.com/in/jino-rohit-6032541b5/

--

--