Build Serverless APIs with Serverless Framework and NodeJs
4.2 (45 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
4,250 students enrolled

Build Serverless APIs with Serverless Framework and NodeJs

Learn how to build and deploy Restful APIs with Serverless Framework, Node.Js, DynamoDB, and AWS
4.2 (45 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
4,250 students enrolled
Created by Haider Malik
Last updated 1/2020
English [Auto]
Current price: $121.99 Original price: $174.99 Discount: 30% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 2 hours on-demand video
  • 7 articles
  • 12 downloadable resources
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Develop and deploy AWS Lambda functions properly with the Serverless Framework
  • Learn the fundamentals of AWS Lambda
  • Learn YAML and manage your entire deployment using code
  • Learn how to build Serverless APIs using offline plugin
  • Deploy Serverless APIs to AWS Provider
Course content
Expand all 28 lectures 02:14:03
+ Introduction
7 lectures 45:23

In this article, You will learn what are the benefits of serverless or when do you need to use serverless

When to use Serverless

YAML is a human-readable data serialization language. It is commonly used for configuration files, but could be used in many applications where data is being stored or transmitted

Yaml Basics

In this video, we will create our first AWS Lambda function

Creating Lambda Function

This Serverless plugin emulates AWS λ and API Gateway on your local machine to speed up your development cycles. To do so, it starts an HTTP server that handles the request's lifecycle like APIG does and invokes your handlers.


  • Node.js λ only.

  • Velocity templates support.

  • Lazy loading of your files with require cache invalidation: no need for a reloading tool like Nodemon.

  • And more: integrations, authorizers, proxies, timeouts, responseParameters, HTTPS, Babel runtime, CORS, etc...

Emulates AWS λ and API Gateway on your local machine

To create HTTP endpoints as Event sources for your AWS Lambda Functions, use the Serverless Framework's easy AWS API Gateway Events syntax.

Create HTTP GET and POST endpoint using API Gateway Event

To pass optional and required parameters to your functions, so you can use them in API Gateway tests and SDK generation, marking them as true will make them required, false will make them optional.

Access Request Parameters in Lambda Function
+ Deploying Serverless API to AWS
4 lectures 20:45

AWS Accounts Include 12 Months of Free Tier Access. In this video, I will show you how to create a new AWS account

Preview 04:53

The Serverless Framework needs access to your cloud provider's account so that it can create and manage resources on your behalf.

This guide is for the Amazon Web Services (AWS) provider, so we'll step through the process of setting up credential for AWS and using them with Serverless.

Preview 02:56

Use this method when you have updated your Function, Event or Resource configuration in serverless.yml and you want to deploy that change (or multiple changes at the same time) to Amazon Web Services.

Deploy Serverless API to AWS Cloud Provider

In this lecture, I will show you how to check logs for your AWS Lambda functions. I will show you how you can view your AWS Lambda settings in the Lambda dashboard

Checking AWS Lambda Configs and Logs
+ DynamoDB Basics
5 lectures 05:31
What is DynamoDB

In this article, You will learn about the core components of DynamoDB

Tables, Items and Attributes in DynamoDB

You will learn about the basics of Primary Keys in DynamoDB Table

Primary Key

In this lecture you will learn what are the three types of Data Types

Data Types in DynamoDB
Secondary Indexes
+ CRUD(Create, Read, Update and Delete) with Serverless and DynamoDB
11 lectures 01:02:21

In this video, we will use serverless-dynamodb-local to setup the local dynamodb server with serverless project.

Serverless Dynamodb Local Plugin - Allows to run dynamodb locally for serverless

Installing DynamoDB on your local Machine

I will show you how to define the DynamoDB table resource in serverless.yml file

Define DynamoDB table in serverless.yaml file

You will learn how to migrate the DynamoDB Tables in serverless project

Create Table a in Local DynamoDB server

Creates a new item, or replaces an old item with a new item. If an item that has the same primary key as the new item already exists in the specified table, the new item completely replaces the existing item. You can perform a conditional put operation (add a new item if one with the specified primary key doesn't exist), or replace an existing item if it has certain attribute values. You can return the item's attribute values in the same operation, using the ReturnValuesparameter.

Save new Record in Local DynamoDB

Imagine you run facebook and you want visitors to sign up on the website with real names and not something like l337_p@nda in the first name field. How would you define the limitations of what can be inputted and validate it against the set rules?

This is joi, joi allows you to create blueprints or schemas for JavaScript objects (an object that stores information) to ensure validation of key information.

Validate request param using Joi package

The Scan operation returns one or more items and item attributes by accessing every item in a table or a secondary index. To have DynamoDB return fewer items, you can provide a FilterExpression operation.

Create GET Endpoint to fetch all the Records from DynamoDB Table

The GetItem operation returns a set of attributes for the item with the given primary key. If there is no matching item, GetItem does not return any data and there will be no Item element in the response.

GetItem provides an eventually consistent read by default. If your application requires a strongly consistent read, set ConsistentRead to true. Although a strongly consistent read might take more time than an eventually consistent read, it always returns the last updated value.

Create GET Endpoint to fetch single Item from DynamoDB Table

Deletes a single item in a table by primary key. You can perform a conditional delete operation that deletes the item if it exists, or if it has an expected attribute value.

In addition to deleting an item, you can also return the item's attribute values in the same operation, using the ReturnValues parameter.

Unless you specify conditions, the DeleteItem is an idempotent operation; running it multiple times on the same item or attribute does not result in an error response.

Conditional deletes are useful for deleting items only if specific conditions are met. If those conditions are met, DynamoDB performs the delete. Otherwise, the item is not deleted.

Create DELETE Endpoint to delete Record from DynamoDB Table

Edits an existing item's attributes, or adds a new item to the table if it does not already exist. You can put, delete, or add attribute values. You can also perform a conditional update on an existing item (insert a new attribute name-value pair if it doesn't exist, or replace an existing name-value pair if it has certain expected attribute values).

You can also return the item's attribute values in the same UpdateItem operation using the ReturnValues parameter.

Create PUT Endpoint to update Record in DynamoDB Table

Variables allow users to dynamically replace config values in serverless.yml config.

They are especially useful when providing secrets for your service to use and when you are working with multiple stages.

Create Env variables for TableName in Serverless

IAM is how you manage access to resources in your AWS account. Who is allowed to create a Lambda function? To delete a function?

This isn't the only IAM guide you'll ever need, but you should understand how IAM works with Lambda and the Serverless Framework. We'll cover the basics of IAM to get you on your way.

In this guide, we'll go over:

  • Basic IAM concepts

  • The two kinds of IAM entities with the Serverless Framework

  • Managing permissions for the Serverless Framework user

  • Managing permissions with your Lambda functions

Deploy Serverless API to AWS
+ Learning Path to become a full-stack developer
1 lecture 00:03
Learning Path to become a full-stack developer
  • Knowledge of Nodejs is required
  • Basic understanding of the AWS Cloud is preferred to take this course

The Serverless Framework is a free and open-source web framework written using Node.js. Serverless is the first framework that was originally developed for building applications exclusively on AWS Lambda, a serverless computing platform provided by Amazon as a part of the Amazon Web Services. Currently, applications developed with Serverless can be deployed to other function as a service providers, including Microsoft Azure with Azure Functions, IBM Bluemix with IBM Cloud Functions based on Apache OpenWhisk, Google Cloud using Google Cloud Functions, Oracle Cloud using Oracle Fn[1], Kubeless based on Kubernetes, Spotinst and Webtask by Auth0.[2]

Serverless is a cloud computing execution model where the cloud provider dynamically manages the allocation and provisioning of servers. A serverless application runs in stateless compute containers that are event-triggered, ephemeral (may last for one invocation), and fully managed by the cloud provider. Pricing is based on the number of executions rather than pre-purchased compute capacity, isn’t it the ideal framework for that project you have been planning since a long time? Well, go ahead do it.

Serverless applications are event-driven cloud-based systems where application development rely solely on a combination of third-party services, client-side logic and cloud-hosted remote procedure calls (Functions as a Service).

Most of the cloud providers have invested heavily in serverless and thats a lot of money; with the given massive promotion and realistic offering you can safely assume serverless to be one of the most used cloud services in upcoming years. Here are some of the currently available cloud services:

  • AWS Lambda

  • Google Cloud Functions

  • Azure Functions

  • IBM OpenWhisk

  • Alibaba Function Compute

  • Iron Functions

  • Auth0 Webtask

  • Oracle Fn Project

  • Kubeless

Traditional vs. Serverless Architecture

For years your applications have run on servers which you had to patch, update, and continuously look after late nights and early mornings due to all the unimaginable errors that broke your production. As long as you managed them, the whole responsibility of their proper functioning was on you. Serverless tends to be unlike the aforementioned, you no longer need to worry about the underlying servers. Reason being, they are not managed by you anymore and with management out of the picture the responsibility falls on the Cloud vendors. But regardless the cool features of Serverless in some cases, the traditional architecture outshines it.


One of the major advantages of using Serverless is reduced cost, for years the cost of provisioning servers and maintaining that 24x7 server team which blew a hole in your pocket is gone. The cost model of Serverless is execution-based: you’re charged for the number of executions. You’re allotted a certain number of seconds of use that varies with the amount of memory you require. Likewise, the price per MS (millisecond) varies with the amount of memory you require. Obviously, shorter running functions are more adaptable to this model with a peak execution time of 300-second for most Cloud vendors.

The winner here is Serverless Architecture.


The downside is that Serverless functions are accessed only as private APIs. To access these you must set up an API Gateway. This doesn’t have an impact on your pricing or process, but it means you cannot directly access them through the usual IP, snap!

The winner here is Traditional Architecture.

3rd Party Dependencies

Most, if not all of your projects have external dependencies, they rely on libraries that are not built into the language or framework you use. You often use libraries with functionality that includes cryptography, image processing, etc., these libraries can be pretty heavy. Without system-level access, you must package these dependencies into the application itself.

Reinventing the wheel isn’t always a good idea.

The winner here is based on the context. For simple applications with few dependencies, Serverless is the winner; for anything more complex, Traditional Architecture is the winner.


Setting up different environments for Serverless is as easy as setting up a single environment. Given that it’s pay per execution, this is a large improvement over traditional servers, you no longer need to set up dev, staging, and production machines. Eventually you’d lose count of all the environments, at some point.

The winner here is Serverless Architecture.


With Serverless computing, there’s a hard 300-second timeout limit. Too complex or long-running functions aren’t good for Serverless, but having a hard timeout makes it impossible to perform certain tasks. A hard limit on this time makes Serverless unusable for applications that have variable execution times, and for certain services which require information from an external source.

The clear winner here is Traditional Architecture.


Scaling process for Serverless is automatic and seamless, but there is a lack of control or entire absence of control. While automatic scaling is great, it’s difficult not to be able to address and mitigate errors related to new Serverless instances.

It’s a tie between Serverless and Traditional Architecture.

Functions as a Service (FaaS)

FaaS is an implementation of Serverless architectures where engineers can deploy an individual function or a piece of business logic. They start within milliseconds (~100ms for AWS Lambda) and process individual requests within a 300-second timeout imposed by most cloud vendors.

Principles of FaaS:

Complete management of servers

Invocation based billing

Event-driven and instantaneously scalable

Key properties of FaaS:

Independent, server-side, logical functions

FaaS are similar to the functions you’re used to writing in programming languages, small, separate, units of logic that take input arguments, operate on the input and return the result.


With Serverless, everything is stateless, you can’t save a file to disk on one execution of your function and expect it to be there at the next. Any two invocations of the same function could run on completely different containers under the hood.


FaaS are designed to spin up quickly, do their work and then shut down again. They do not linger unused. As long as the task is performed the underlying containers are scrapped.


Although functions can be invoked directly, yet they are usually triggered by events from other cloud services such as HTTP requests, new database entries or inbound message notifications. FaaS are often used and thought of as the glue between services in a cloud environment.

Scalable by default

With stateless functions multiple containers can be initialised, allowing as many functions to be run (in parallel, if necessary) as needed to continually service all incoming requests.

Fully managed by a Cloud vendor

AWS Lambda, Azure Functions, IBM OpenWhisk and Google Cloud Functions are most well-known FaaS solutions available. Each offering typically supports a range of languages and runtimes e.g. Node.js, Python, .NET Core, Java.

Who this course is for:
  • Developers who want to learn about AWS Lambda and the Serverless Architecture
  • Developers who want to build Serverless APIs using Serverless Framework, AWS and NodeJs