Chapter 7. Serverless Functions In-Depth: Part 2

So far, we have covered quite a bit of functionality that can be achieved using a Lambda function. In this chapter, we’ll continue learning how to use Lambda functions in different ways to implement common functionality you’ll find useful when building applications. We’ll get into how to create and integrate into our app a fully functional backend complete with an API, authentication, a database, and authorization rules.

With Amplify, there are two main ways to create APIs: GraphQL and REST. We’ll continue to cover GraphQL in Chapter 8, but here, we’ll learn how to do this with a REST API running in a Lambda function.

The database we will use is Amazon DynamoDB, a NoSQL database. We will be invoking the Lambda function from an HTTP request routed through an API gateway endpoint. The Lambda function will take the HTTP request and then route it to different paths as the function will be running an Express web server.

This will allow us to have different routes available within a single function. We will then map different HTTP methods, like post and delete, to the routes to perform different actions on the database.

What We’ll Build

We’ll be building a basic ecommerce app that allows users to view products, and administrators to create and delete products. The building blocks of this app will lay the groundwork for building almost any type of CRUD+L (create, read, update, delete, and list) application, which is the backbone of many ...

Get Full Stack Serverless now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.