Flask Lambda Lab – Lesson 5

Lesson Overview

Sorry to say, were almost done. We just need to clean up.


  1. Undeploy your Lambda application
  2. The following command will remove all of the resources that zappa deployed into AWS including API Gateway, Lambda functions & IAM roles and triggers.

    zappa undeploy dev
  3. Remove your flasklambdalab-* S3 buckets
    • This script deletes the S3 buckets that we created for this lab and all of their contents. It also moves the zappa_config.json file and bucketConfig.py file to the ./backups directory ./delete_s3_buckets.py
  4. Terminate your EC2 development instance
  5. The following commands will `permanently terminate` the EC2 instance in which you run the command. Upon completion of the command, your ssh session will terminate and the EC2 instance will be gone forever

    export AWS_DEFAULT_REGION=`curl -s | sed -e 's:\([0-9][0-9]*\)[a-z]*\$:\\1:'`
    curl -s | xargs -i aws ec2 terminate-instances --instance-ids {}
    • If you don’t want to destroy the EC2 instance, you can just shut it down instead so that it can resumed at a later time using the following command. Your account will be charged for the EBS storage volume that will remain

      export AWS_DEFAULT_REGION=`curl -s | sed -e 's:\([0-9][0-9]*\)[a-z]*\$:\\1:'`
      curl -s | xargs -i aws ec2 stop-instances --instance-ids {}

Lesson Summary

In this lesson, we:

  1. Removed our lambda resources that were deployed with zappa
  2. Removed the S3 buckets that we created for this project
  3. Deleted the EC2 instance we used for downloading & deploying code

Things to try on your own

  1. Register a DNS name on [Route53](https://aws.amazon.com/route53/) for $12 and use zappa certify to register an SSL certificate.
  2. Try a global deployment of your Flask/Lambda app into all AWS regions at once! Now that’s HA!
  3. Use the PynamoDb library to connect you Flask application an effortlessly scalable database like DynamoDb and store more information
  4. Build more lambda functions that are triggered by upload events that do things like facial recognition using AWS Rekognition