Sign in

Launching an application with Zappa

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.

Photo by Dallas Reedy on Unsplash

Our requirements.txt

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.

Runpip 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.source [virtualenv]/bin/activate

Now that you are in a python virtual environment, you can install the final dependencies with a simple pip install: pip install flask zappa

Configuring zappa_settings.json

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 andzappa 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 iszappa 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!

Zappa is one of my favorite tools for deploying and managing lambda functions. It’s flexible and easy to use. If you are having any issues see Zappa’s GitHub page for more info or feel free to contact me.

AWS Community Builder & Cloud Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store