Deploying a Flask application to AWS

An end-to-end example using Amazon’s Elastic Beanstalk and RDS

Scott Rodkey


(Note: Updated Jan 2019 with latest AWS interfaces)

Flask is awesome. It’s the easiest way to learn web development. Start small, and then you can quickly add any upgrades you need — email, databases, forms, etc.

Amazon Web Services is fantastic. There are a ton of cloud platforms out there, but none are more flexible than AWS. It seems like you can do anything on Amazon — host websites, create scalable databases, send emails, text messages, stream live video from your home — the possibilities are endless.

The two seem like a natural fit. Create a killer Flask app and then push it to AWS. Easy, right?

But there are a surprising lack of examples on the web. The official documentation is recommended, but lacks visuals which can help beginners.

Don’t get me wrong, there are some good blog posts that help with common stumbling blocks. But I couldn’t find an end-to-end example for deploying a Flask application to AWS.

So here’s a step-by-step tutorial that will launch your Flask application to AWS Elastic Beanstalk. It also uses AWS RDS for a database backend.

Let’s dive in:

Step 0: Create an AWS account

What are you waiting for? Sign up!

Note: AWS requires a credit card for registration. But our example will exist entirely on the AWS Free Tier, so you won’t be charged.

Step 1: Download the Flask example code

Fork my Github repo:

We’re going to deploy a simple app that reads and writes from a database using Flask-SQLAchemy. Dig into the code if you’d like — it should run locally if you run python (after you set you the environment in Step 4).

Step 2: Set up your Flask environment

In the directory where the example code exists, create a Python virtual environment.

$ virtualenv flask-aws

$ source flask-aws/bin/activate

Then install the packages needed for this demo with: