Flask Lambda Lab

Quickly build an infinitely scale-able serverless web application that runs on AWS lambda for just pennies per month. Cloud Shift Strategies will lead an interactive workshop where each attendee will build a simple Flask based web application and deploy it to lambda. No programming skills are required!


Learn to quickly build an infinitely scale-able serverless web application that runs on AWS lambda for just pennies per month.


  • A basic understanding of the Linux command shell
  • A basic understanding of AWS services like EC2 and S3 storage is a plus

What to bring

  • Laptop with a ssh client ([Putty](http://www.putty.org/) for Windows)
  • A mouse will be helpful for fast copy/pasting
  • An AWS Free Tier account [aws.amazon.com/free](http://aws.amazon.com/free) (ideally, create a new account with no other resources deployed)

What we’ll build

  • In this lab we’ll build a simple web based photo album that is deployed in a unique manner – *Totally Serverless!*
  • This application can easily and affordably scale to infinity using AWS API Gateway, Lambda serverless computing and S3. And the best part… it’s EASY!

How it works

  • The user’s web browser connects to a URL for an API gateway.
  • The API gateway acts as the “front door” for applications to access back end lambda functions
  • Our Flask web code will run in an AWS Lambda function which dynamically creates html pages to be sent back to the browser
  • Static content (like images) are stored in an s3 bucket with web site access enabled
  • The user’s browser will upload image files to the s3 bucket┬ádesignated for uploads.
  • When an image lands in the uploads s3 bucket, our s3_UploadTrigger lambda function is called, which creates a thumbnail, stores it in the Thumbnails bucket, stores the url to the thumbnail as metadata on the uploaded image

Scaling our application, the old way

  • We could deploy this application in a typical 3 tier application architecture, where Linux VMs or Docker Containers run the web and application code. And this is how it is typically done.
  • But as the demands on the application increase, we need to increase the capacity and redundancy of the application.
  • We can add load balancers and auto-scaling groups spanning multiple availability zones. Our databases can have replicas and the app can have local read affinities. We can even duplicate all this to another region to be safe.
  • Fortunately, this is all automatable thanks to AWS and Infrastructure as Code tricks. But it’s still really complicated, and it can be really expensive too.

Scaling our application, the lambda way

  • It’s already done. Really!
  • The API Gateway and s3 buckets used in our applications are already massively scalable and available. We don’t have to do anything.
  • Each web browser request, invokes a new lambda instance. Each one is created, executed and dies in less than 30ms!
  • This means that if nobody is visiting your site, you are using no resources. (no $$) If your uber application has millions of concurrent visitors, AWS will deploy millions of lambda instances, AUTOMATICALLY!
  • If you want multi-region redundancy, deploy your function to multiple regions and tell your DNS server (route 53) about each API gateway.

Up Next

In Lesson 1, we will build out a development environment that we can use to download and deploy a flask based application to AWS lambda