In this walkthrough, I’ll be making use of the Serverless Framework to build and deploy a simple Node.js API to Lambda and API Gateway. Our data will be stored using Amazon Relational Database Service (RDS) for PostgreSQL.Installing the Serverless Framework CLI

Let’s start by installing the serverless npm package. By using the -g flag, the package is installed globally on your machine.

npm install -g serverless

Creating a new project

serverless

Running the command serverless will guide you through creating a new serverless project. Select AWS Node.js as your template and then provide a meaningful name for the project. I’ll call mine serverless-tutorial-rds.

Image for post

Now to add a package.json file by initialising the directory as a new npm package. Firstly navigate into the new projects directory and then run npm init. You can use the flag -y to skip the various npm package settings.

cd serverless-tutorial-rds
npm init -y

Project Structure

Open the project in your text editor of choice and you’ll see what files were created for us. The Serverless.yml file is where we define our functions, the events that trigger them, and the resources they use. The handler.j_s _file is where we will maintain the logic for our functions.

Image for post

#api #aws-lambda #serverless #aws #postgres

 Build and Deploy a Simple Node.js API to Lambda and API Gateway.
5.05 GEEK