10 - Creating APIs in AWS

by Alejandro Correa Bahnsen and Jesus Solano

version 1.4, February 2019

Part of the class Practical Machine Learning

This notebook is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

AWS

It is going to take you time to register ...

Log in into the AWS Management Console

Wait until the account is activated

Creating a EC2 instance

Configure Security group

Add TCP port 5000 (used by flask)

Launch

Instance Security

Done

Conecting to the AWS Instance

Follow the tutorial on https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstances.html

Test connection

Deploy Flask API

Install anaconda

wget https://repo.anaconda.com/archive/Anaconda3-2018.12-Linux-x86_64.sh

bash Anaconda3-2018.12-Linux-x86_64.sh

Test the instalation

If not Anaconda do:

export PATH="/home/ubuntu/anaconda3/bin:$PATH"

Copy files

git clone https://github.com/albahnsen/PracticalMachineLearningClass.git

Go to the model_deployment folder

Install the additional libraries

pip install flask-restplus

Deploy the Flask API

nohup python api.py &

Check the Flask API

Go to -ec2-machine-ip-:5000

In my example http://54.175.140.184:5000/

Command to get process number and finish it

ps -ef |grep jupyter Next use the command kill -9 xxxx xxxx is the process number


In [ ]: