Book Image

Building Serverless Microservices in Python

By : Richard Takashi Freeman
Book Image

Building Serverless Microservices in Python

By: Richard Takashi Freeman

Overview of this book

Over the last few years, there has been a massive shift from monolithic architecture to microservices, thanks to their small and independent deployments that allow increased flexibility and agile delivery. Traditionally, virtual machines and containers were the principal mediums for deploying microservices, but they involved a lot of operational effort, configuration, and maintenance. More recently, serverless computing has gained popularity due to its built-in autoscaling abilities, reduced operational costs, and increased productivity. Building Serverless Microservices in Python begins by introducing you to serverless microservice structures. You will then learn how to create your first serverless data API and test your microservice. Moving on, you'll delve into data management and work with serverless patterns. Finally, the book introduces you to the importance of securing microservices. By the end of the book, you will have gained the skills you need to combine microservices with serverless computing, making their deployment much easier thanks to the cloud provider managing the servers and capacity planning.
Table of Contents (13 chapters)
Title Page

Book summary

In Chapter 1Serverless Microservices Architectures and Patterns, we started by looking at the different architectures that are used in many organizations. Rather than having you read many architecture books, watch many courses, and read numerous blog posts, we summarized the important principles and concepts. We focused on monolithic/multitier architecture, SOA, and microservices in particular. Then, we compared virtual machines, containers, and serverless computing by covering the benefits of using a serverless stack, such as pay per execution time, autoscaling inbound integration, and IAM role-based security. We explained some of the important microservice integration patterns and software design patterns and principles, and also covered the relevant serverless communication microservice patterns. We concluded this chapter by setting up our serverless environment in AWS, which included Bash, Python, and the AWS CLI.

In Chapter 2Creating Your First Serverless Data API, we walked through how to create our first serverless data API with the AWS Management Console. We deliberately chose the console as it has a user interface, thereby allowing you to build your stack visually. We believe that it is very important to understand the details of it as this helps you gain a natural intuition and understanding of serverless in AWS, which will be important further down the line. We started with an overview of security linked to IAM, DynamoDB, Lambda, and API Gateway. Then, we stepped through the serverless microservice data API requirements and architecture and walked through all the steps that are needed to build every service or resource in the serverless stack. This included the highly available and managed NoSQL database known as DynamoDB, setting up an API Gateway to receive HTTP requests at scale, and using Lambda to act as a data access layer and the business logic glue between them.

In Chapter 3, Deploying Your Serverless Stack, we focused on building and deploying our serverless stack using tools instead of doing it manually in the console. This is particularly important as you always want to deploy services and infrastructure in a production environment. In this book, we made use of the AWS serverless application model (SAM) templates and CloudFormation to build and deploy the serverless stack. Making use of these SAM templates saves time and allows you to support multiple environments and make changes in a controlled and repeatable way compared to configuring them manually.

In Chapter 4, Testing Your Serverless Microservice, we focused on testing our serverless microservice and covered a wide variety of tests that are relevant for serverless architectures. This included unit testing, mocking, debugging locally, integration testing, end-to-end testing, and load testing. We had to make full use of Bash or Python scripts, which allow you to quickly replicate such tests in your organization.

In Chapter 5, Securing Your Microservice, we talked about securing our microservice and the options that are available in AWS to secure all the resources and services in our serverless microservices stack. This included discussing AWS Identity and Access Management (AWS IAM). We also discussed how Lambda security works with respect to IAM and inbound integration with event sources, along with other AWS resources. Then, we talked about how we can make DynamoDB secure.