The goal of this Kata is get this tiny flask app up and running in 3 different ways and send me the url so that I can access it (NB!).
These are the 3 different ways:
- Locally on your own machine
- Using infrastructure in AWS (EC2)
- Using application services in AWS (Elastic Beanstalk)
There are also 3 STRETCH challenges for those who manage to complete those 3 and can come show me. If you've managed, come let me know.
For this one, I'll give you some guidance. Time limit: 1 hr
- Install python (This should have been done)
- Install postgresql (This should have been done)
git clone git@github.com:jaderabbit/cloudkata.git
cd path/to/cloudkata
pip install -r requirements.txt
- Create a user called
test
with passwordtest
: - Create a database called
test
.
- FLASK_APP=application.py
- DBUSER=test
- DBPASS=test
- DBHOST=localhost
- DBNAME=test
In windows (run cmd as command):
setx -m FLASK_APP "application.py"
echo %FLASK_APP%
In linux:
export FLASK_APP=application.py
echo $FLASK_APP
cd path/to/cloudkata/app
flask db upgrade && flask run -h 0.0.0.0 -p 5000
- Go to
http://0.0.0.0:5000/
in your browser
Hint: Experts would grok this pretty quickly
It's a hardware that you can rent online. Or in fancy words: "is a form of cloud computing that provides virtualized computing resources over the internet"
It's Amazon web services IaaS. It's a VM in the cloud.
For the web server:
- Create an EC2 box (linux!).
- Download the certificate.
- Setup your ssh credentials for the box using the certificate. (putty & puttygen or OpenSSL - you might have installed OpenSSL when you installed git!)
- Login to your EC2 box
- Clone the github repo and install the web server: similar to the first kata
- Install postgresql: https://github.com/snowplow/snowplow/wiki/Setting-up-PostgreSQL
- Setup the security groups so we can access it. (Do as demoed! Open up the ports!)
- Send me you URL when it works.
Use Elastic Beanstalk to install and run the python web server, and then use it to create an RDS instance for the database. You'll need to set environment variables here too, but they can be done via the interface
You have the option of using the INTERFACE or using the AWS CLI
Interface:
- Create an elastic beanstalk app
- Update the WSGIPath to point to app/application.py
- Create a database by going to the elastic beanstalk configuration and clicking on database and creating a new postgres database
- Once created, go to the elastic beanstalk configuration and click software. Add your environment variables
- Challenge: Run Migrations on startup! You'll need to create a folder with the flask command
CLI:
Platform as a Service is an abstraction away from the hardware or VM. It's meant to remove the low level installation, running and management of services.
AWS Elastic Beanstalk is what we call an "application service". It makes deploying technologies super easy via the use of a super simple wizard. Additionally, it makes autoscaling, load-balancing and a variety of other things, SUPER easy
AWS RDS is a database service. Almost had it with installing postgresql in various places? Well, now you need not worry: AWS RDS handles that for you