In this guide, I walk you through building and automating the deployment of a serverless CRUD REST API using Node.js, AWS Lambda, API Gateway, DynamoDB, Serverless Framework, and GitHub Actions CI/CD.

I’ll build a Coffee Shop API to to manage orders, inventory, and customer requests, deploying it automatically whenever code changes are pushed.

Prerequisites

Before starting, verify if you have:

  • Node.js and npm installed

  • AWS CLI configured for your AWS account

  • Serverless Framework account and CLI installed globally

Use Case Scenario 

In a coffee shop located near Downtown Houston, the owner DJ managed orders and inventory with traditional web hosting, manually handling multiple servers and databases.

As the shop gained popularity, DJ’s setup struggled with:

  • Scaling to handle sudden spikes in orders

  • Rising infrastructure costs

  • Difficulty adding new features like loyalty programs or personalized recommendations

DJ is also a cloud engineer.  He decides to deploy a serverless architecture, that can handle scaling and infrastructure. With serverless, every coffee order becomes an event that triggers Lambda functions to interact with DynamoDB.

DJ intends to use the pay-as-you-go model. He will only pays for the compute time used, and with automation via the Serverless Framework and GitHub Actions, updates are deployed instantly without manual intervention.

Objectives

At the end of this project, you will have learned how to:

  1. Set up the Serverless Framework environment

  2. Define the API in serverless.yml

  3. Create Lambda functions for CRUD operations

  4. Configure multi-stage deployments (dev/prod)

  5. Automate deployments with GitHub Actions CI/CD

  6. Test APIs with Postman

Step 0 – Clone the Repository

  • Clone the project from GitHub and review the included files
  • Use them to build the Coffee Shop API.

Step 1 – Set Up Serverless Framework

I need to authenticate my account via the CLI by creating an access key to enable automated deployments with the Serverless Framework. This key, stored securely as a GitHub secret, allows the CI/CD pipeline to deploy my application without exposing credentials. I created it in my Serverless account under Access Keys and named it SERVERLESS_ACCESS_KEY. Do the same following these: 

  • Save it securely and add it as SERVERLESS_ACCESS_KEY in your GitHub repository secrets

This key lets the CI/CD pipeline authenticate with Serverless during deployments.

Step 2 – Define API in serverless.yml

I created serverless.yml file that defines the Coffee Shop API’s infrastructure on AWS using the Serverless Framework. It configures API Gateway for POST, GET, PUT, and DELETE requests, four Lambda functions for CRUD operations, and a DynamoDB table with environment-specific naming for dev and prod. IAM permissions, dynamic stage deployment, and pay-per-request billing are all set up to allow easy scaling and management without manual provisioning.

Configuration includes:

  • AWS as the provider with Node.js runtime

  • Region (us-east-2) and dynamic stage (dev/prod)

  • IAM permissions for Lambda to access DynamoDB

  • Four Lambda functions:

  • A DynamoDB table with pay-per-request billing

Dynamic naming ensures resources are separate for dev and prod (e.g., CoffeeOrders-dev vs. CoffeeOrders-prod).

Step 3 – Build Lambda Functions

Each function uses AWS SDK and DynamoDB DocumentClient:

  • Create Coffee – Adds a new coffee order with a unique OrderId

  • Get Coffee – Retrieves all orders

  • Update Coffee – Updates order details or status

  • Delete Coffee – Cancels an order by ID and customer name

Each function uses environment variables for the table name, returns a 200 response on success, and a 500 response with an error message on failure.

Step 4 – Configure CI/CD with GitHub Actions

Stay with me as I configure AWS secrets for my GitHub Actions pipeline, added AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and SERVERLESS_ACCESS_KEY .

The pipeline uses a branching strategy where dev deploys to a development environment and main deploys to production. A GitHub Actions workflow then installs dependencies, sets up the Serverless Framework, and conditionally deploys to AWS based on the branch, using the stored secrets for secure authentication.

Here’s how to do it:

  1. In GitHub, go to Settings → Secrets and variables → Actions

  2. Add:

    • AWS_ACCESS_KEY_ID

    • AWS_SECRET_ACCESS_KEY

    • SERVERLESS_ACCESS_KEY

2. Use main for production and dev for development

3. Workflow automates:

    • Installing Node.js & dependencies

    • Installing Serverless Framework

    • Deploying to dev on dev branch push

    • Deploying to prod on main branch push

Step 5 – Test the Pipelines

Now, it’s time to test what I built so far. 

I start with a main branch for production and a dev branch for development. Then:

  • Push changes to dev → Deploys to dev environment

  • Merge into main → Deploys to production

  • Monitor deployment logs in the Actions tab

Step 6 – Test APIs with Postman

After deployment, I retrieve my  API endpoints from the GitHub Actions logs by opening the latest successful build for your chosen environment (Dev or Prod) and checking the “Deploy to AWS” stage.

Use these URLs to test the API in a browser or Postman, verifying CRUD functionality. GET should return an empty list initially, while POST, PUT, and DELETE should create, update, and remove orders in DynamoDB. Repeat the process for both environments to confirm everything is working correctly.

Your turn, test it now:

  1. Get API URLs from GitHub Actions logs

  2. GET – Initially returns an empty list of coffee orders

  3. POST – Creates a new coffee order with customer and blend details

  4. PUT – Updates order status (e.g., “Ready”)

  5. DELETE – Cancels an order

Verify each operation by checking DynamoDB tables for the correct environment.

You’ve now built and automated a fully serverless CRUD REST API for a coffee shop, using AWS Lambda, API Gateway, DynamoDB, Serverless Framework, and GitHub Actions; scalable, cost-efficient, and maintenance-free.

Find the full repo here: https://github.com/djcloudking/coffee-shop-crud-api-node-js-project 

Leave a Reply

Your email address will not be published. Required fields are marked *