Book Image

AWS Lambda Quick Start Guide

By : Markus Klems
Book Image

AWS Lambda Quick Start Guide

By: Markus Klems

Overview of this book

AWS Lambda is a part of AWS that lets you run your code without provisioning or managing servers. This enables you to deploy applications and backend services that operate with no upfront cost. This book gets you up to speed on how to build scalable systems and deploy serverless applications with AWS Lambda. The book starts with the fundamental concepts of AWS Lambda, and then teaches you how to combine your applications with other AWS services, such as AmazonAPI Gateway and DynamoDB. This book will also give a quick walk through on how to use the Serverless Framework to build larger applications that can structure code or autogenerate boilerplate code that can be used to get started quickly for increased productivity. Toward the end of the book, you will learn how to write, run, and test Lambda functions using Node.js, Java, Python, and C#.
Table of Contents (8 chapters)

Building a Serverless backend with Python

In the previous section, we created a simple Lambda function using the serverless framework and Python. Now we will create a more complex service similar to the one that we created using Node.js, but using Python. In this section, we will refactor the Lambda function from our previous section. We will add DynamoDB for data persistence, create the other CRUD operations, and test our deployed service using Postman.

Go back to the Atom Editor where we last left off. Let's refactor the handler function a little bit. For example, we're going to replace the body with a short message, Created new article.

Let's print out the event that the Lambda function has been invoked with. Instead of naming the function handler hello, we simply rename it handler:

def handler(event, context):
print('received event{}'.format(event...