Book Image

Building Serverless Python Web Services with Zappa

By : Abdulwahid Abdulhaque Barguzar
Book Image

Building Serverless Python Web Services with Zappa

By: Abdulwahid Abdulhaque Barguzar

Overview of this book

Serverless applications are becoming very popular these days, not just because they save developers the trouble of managing the servers, but also because they provide several other benefits such as cutting heavy costs and improving the overall performance of the application. This book will help you build serverless applications in a quick and efficient way. We begin with an introduction to AWS and the API gateway, the environment for serverless development, and Zappa. We then look at building, testing, and deploying apps in AWS with three different frameworks--Flask, Django, and Pyramid. Setting up a custom domain along with SSL certificates and configuring them with Zappa is also covered. A few advanced Zappa settings are also covered along with securing Zappa with AWS VPC. By the end of the book you will have mastered using three frameworks to build robust and cost-efficient serverless apps in Python.
Table of Contents (20 chapters)
Title Page
Dedication
Packt Upsell
Contributors
Preface
Index

Preface

This book is based on the modern way of developing a serverless Python-based web or microservices. Being serverless involves a serverless infrastructure provided by the cloud service provider. This book shows how to use Amazon Web Services to implement the serverless infrastructure. Also, it covers the deployment process using Zappa. Zappa eliminates manual intervention, gives you an automated way to proceed deployment, and helps you maintain multiple deployment stages.

Who this book is for

This book is for beginner to experienced Python developers who want to understand the way to develop Python web services or microservices on the serverless infrastructure. Experienced Python developers can enhance their skills by learning about the serverless technology and understanding serverless deployment.

What this book covers

Chapter 1, Amazon Web Services for Serverless, covers understanding the basics of AWS Lambda and API Gateway services. Also, the manual process of creating a serverless service by interacting with the AWS console and CLI tool is covered.

Chapter 2, Getting Started with Zappa, explains the concept of the Zappa tool and elaborates the benefits of using Zappa over the manual process of AWS services.

Chapter 3, Building a Flask Application with Zappa, explores basic Flask application development and deployment using Zappa as a serverless application.

Chapter 4, Building a Flask-Based REST API with Zappa, presents the Flask-based RESTful API development and deployment process with Zappa.

Chapter 5, Building a Django Application with Zappa, discusses Django core application development and deploying the application as a serverless over AWS Lambda using Zappa.

 

 

Chapter 6, Building a Django REST API with Zappa, focuses on RESTful API implementation using the Django REST framework and the deployment process using Zappa.

 

Chapter 7, Building a Falcon Application with Zappa, takes you through developing a RESTful API as a microservice using the Falcon framework and the deployment process using Zappa.

Chapter 8, Custom Domain with SSL, explains how to configure a custom domain with Zappa and also covers SSL generation using AWS.

Chapter 9, Asynchronous Task Execution on AWS Lambda, showcases the implementation of asynchronous operations for the time-consuming task of using Zappa.

Chapter 10, Advanced Zappa Settings, familiarizes you with the additional settings of the Zappa tool to enhance the application deployment process.

Chapter 11, Securing Serverless Applications with Zappa, outlines the security aspect of a serverless application over AWS Lambda using Zappa.

Chapter 12, Zappa with Docker, presents application development with AWS Lambda context environment using Docker containerization.

To get the most out of this book

Before starting, there are some prerequisites that readers require. Readers should have the following:

  • Good understanding of the virtual environment
  • Understanding of Python package installation
  • Knowledge of traditional deployment using Apache or NGINX
  • A basic knowledge of web services or microservices

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

 

You can download the code files by following these steps:

  1. Log in or register at www.packtpub.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Building-Serverless-Python-Web-Services-with-Zappa. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalogue of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the colour images

We also provide a PDF file that has colour images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/BuildingServerlessPythonWebServiceswithZappa_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in the text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Zappa deployment requires the zappa_settings.json file, which generates the zappa init command."

A block of code is set as follows:

client = boto3.client('lambda')
response = client.invoke(
    FunctionName='MyFunction',
    InvocationType='Event'
)

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

$ curl https://quote-api.abdulwahid.info/daily
{"quote": "May the Force be with you.", "author": "Star Wars", "category": "Movies"}

Any command-line input or output is written as follows:

$ pip install awscli

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialogue boxes appear in the text like this. Here is an example: "Click on the Create a function button."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packtpub.com.