Over a year ago now, I came across a fancy little library called Zappa. For those unaware, Zappa is a serverless framework for Flask and Django. In this case, it runs on the AWS cloud using API Gateway to call lambda functions. It is an excellent solution for creating REST APIs or low traffic website, and since it is serverless, it can scale relatively easily. So let’s launch a simple flask application with Zappa.
Zappa is a framework for Flask, so that means python. Luckily because it’s in python, as long as you have it installed correctly, additional dependencies are generally very easy to install. In this case, we’ll need to begin by setting up a virtual environment for Zappa to run in.
pip install virtualenv to install the virtual environment library. From there it as simple as CDing into your project directory and run the command
virtualenv [Name of your virtualenv] Now that the virtual environment is created, to activate it, if you are on windows, do while
[virtualenv]/bin/active on Linux, you are going to want to run.
Now that you are in a python virtual environment, you can install the final dependencies with a simple pip install:
pip install flask zappa
We will be deploying a simple HTTPS application that returns a string input. Before we can deploy, we need to configure our deployment. To do this, we can just run the command and
zappa init follow it’s instructions.
Deploy your application
Now that you have configured your Zappa deployment, we can now actually deploy that configuration. It’s as easy as running the command,
zappa deploy optionally if you set up multiple stages within a single settings file, the command is
zappa deploy (stage) .
Whenever you would like to update your application, all you run is.
zappa update (stage)
Congratulations, if you had no issues, you should have been given a URL where you can test your application!