Skip to content

About

Serverless REST API using AWS Lambda, API Gateway, and DynamoDB for full CRUD functionality. Built with Python and tested using Postman. Scalable, event-driven, and cost-efficient.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Serverless CRUD Application using AWS Lambda, API Gateway & DynamoDB

This project demonstrates how to build a fully serverless, scalable, and pay-per-use CRUD REST API using AWS Lambda, Amazon API Gateway, and Amazon DynamoDB.
It supports Create, Read, Update, and Delete operations, all triggered through API endpoints.


Tech Stack

  • AWS Lambda – Serverless compute for executing backend logic.
  • Amazon API Gateway – To expose RESTful API endpoints.
  • Amazon DynamoDB – NoSQL database for storing data.
  • AWS IAM – To manage secure permissions for Lambda.
  • Amazon CloudWatch – For logging and monitoring.
  • Amazon SNS – For alert notifications.

Project Architecture Overview

High-Level Flow:

Client (Postman / Browser)
   ↓
API Gateway (REST Endpoints)
   ↓
AWS Lambda (CRUD Functions)
   ↓
DynamoDB (ItemsTable)
   ↓
CloudWatch (Logs & Metrics)

AWS CRUD API high level arcitecture diagram
AWS CRUD API Detailed arcitecture diagram

Step-by-Step Workflow

Below is the exact workflow I followed to build this project from scratch:


1️) Create the DynamoDB Table

  • Go to AWS Console → DynamoDB → Create Table
  • Table name: ItemsTable
  • Partition key: id (String)
  • Keep other settings as default (On-Demand capacity)
  • Click Create Table

Screenshot 2025-10-18 114328
Screenshot 2025-10-18 114457

Result:- DynamoDB table ready to store items.


2️) Create IAM Role for Lambda

  • Go to IAM → Roles → Create Role
  • Trusted entity type: AWS Service
  • Use case: Lambda
  • Attach policies:
    • AmazonDynamoDBFullAccess
    • CloudWatchFullAccess
  • Name the role: LambdaDynamoDBRole
  • Click Create Role

Screenshot 2025-10-18 122441
Screenshot 2025-10-18 123033

Result:- A secure role with DynamoDB & CloudWatch permissions created.


3️) Create Lambda Functions

We created 4 Lambda functions, one for each CRUD operation.

Function Name Purpose Operation
CreateItemFunction Adds a new item to DynamoDB POST /items
GetItemsFunction Retrieves all items GET /items
UpdateItemFunction Updates an existing item PUT /items/{id}
DeleteItemFunction Deletes an item by ID DELETE /items/{id}

Each Lambda uses Python (boto3) to interact with DynamoDB.


Screenshot 2025-10-18 123907
Screenshot 2025-10-18 124523
Screenshot 2025-10-18 133123
Screenshot 2025-10-18 133804
Screenshot 2025-10-18 133949

Result:- All Lambda functions tested successfully inside AWS Lambda Console.


4️) Connect API Gateway to Lambda

  • Go to API Gateway → Create API → REST API
  • Create a new Resource named /items
  • Under /items, create the following Methods:
    • POST → Integrate with CreateItemFunction
    • GET → Integrate with GetItemsFunction
  • Create another resource /items/{id}
    • PUT → Integrate with UpdateItemFunction
    • DELETE → Integrate with DeleteItemFunction
  • Enable Lambda Proxy Integration for all.

Screenshot 2025-10-18 135748
Screenshot 2025-10-18 140759
Screenshot 2025-10-18 140851
Screenshot 2025-10-18 141118
Screenshot 2025-10-18 142222
Screenshot 2025-10-18 142339
Screenshot 2025-10-18 142549

Result: API Gateway connected with all Lambda functions.


5️) Deploy the API

  • Go to Actions → Deploy API

  • Create a new stage named prod

  • Copy the Invoke URL, e.g.:

    https://<api-id>.execute-api.<region>.amazonaws.com/prod
    

    Screenshot 2025-10-18 142659

Result: Public API endpoints are now live and callable from Postman.


6️) Test Using Postman

Use the following endpoints:

Method Endpoint Description Example Body
POST /items Create an item { "name": "Test Item", "description": "Created via Postman" }
GET /items Read all items —
PUT /items/{id} Update an item { "name": "Updated Item", "description": "Modified" }
DELETE /items/{id} Delete an item —

Screenshot 2025-10-18 170917
Screenshot 2025-10-18 170932
Screenshot 2025-10-18 170942
Screenshot 2025-10-18 170949

Result: All CRUD operations returned correct responses and updated DynamoDB successfully.


Step 7: Add Monitoring & Alerts using CloudWatch and SNS

Monitoring and alerting are crucial for production-grade systems. Below are the exact steps I followed to enable logging, monitoring, and alert notifications for my Lambda functions.

PART 1 — Enable and View CloudWatch Logs for Lambda

Every Lambda automatically sends logs to CloudWatch, but let’s confirm and check them.

Steps:

  1. Go to AWS Console → Lambda → your function (e.g., CreateItemFunction)
  2. Scroll down to Monitor → View logs in CloudWatch
  3. You’ll see a log group like:
    /aws/lambda/CreateItemFunction
    
  4. Inside this log group, you can open individual Log Streams to view:
    • Start and end time of Lambda invocation
    • Any print() or console.log() outputs
    • Error messages if Lambda failed

Screenshot 2025-11-01 232449
Screenshot 2025-11-01 232602
Screenshot 2025-11-01 233303

Result:
Lambda is already logging to CloudWatch automatically.
Now let’s turn those logs into alerts.

PART 2 — Create a CloudWatch Alarm + SNS Email Alert

This will send me an email when Lambda fails (e.g., due to an exception or timeout).

Create an SNS Topic

  1. Go to AWS Console → SNS → Topics → Create Topic
  2. Choose Standard type
  3. Name it something like:
    LambdaErrorAlerts
    
  4. Click Create topic

Screenshot 2025-11-01 233807
Screenshot 2025-11-01 233827

Subscribe to the Topic

  1. After creating the topic → Click on it → Create Subscription
  2. Protocol → Email
  3. Endpoint → Enter your email address (the one you want alerts on)
  4. Check your inbox and click Confirm subscription

Once confirmed, the status will show as Confirmed in the SNS dashboard.


Screenshot 2025-11-01 233845
Screenshot 2025-11-01 234116

Create a CloudWatch Alarm for Lambda

  1. Go to AWS Console → CloudWatch → Alarms → All Alarms → Create alarm
  2. Choose Select metric
  3. Choose:
    Lambda Metrics → By Function Name → <YourFunctionName> → Errors
    
  4. Click Select metric
  5. Under Conditions, set:
    • Threshold type → Static
    • Whenever Errors is ≥ 1 for 1 datapoint
  6. Under Actions → Alarm state trigger → In Alarm, select:
    • Send a notification to → LambdaErrorAlerts
  7. Give it a name:
    LambdaErrorAlarm-CreateItemFunction
    
  8. Click Create Alarm

We can repeat this for your other functions too(Get, Update, Delete).


Screenshot 2025-11-01 234251
Screenshot 2025-11-02 000302
Screenshot 2025-11-02 000309
Screenshot 2025-11-02 001116
Screenshot 2025-11-02 001736
Screenshot 2025-11-02 002010

Final Result:
The system now automatically sends email alerts whenever any Lambda function fails.


Project Highlights

  • 100% Serverless (no servers or EC2 required)
  • Pay-per-use pricing
  • Scalable CRUD API
  • Clean IAM-based security
  • Tested with Postman
  • Observable with CloudWatch

Learnings & Key Takeaways

  • Gained hands-on experience with AWS Lambda and API Gateway integration
  • Learned to manage IAM roles & permissions effectively
  • Understood DynamoDB CRUD operations using boto3
  • Practiced API testing with Postman
  • Created a scalable, production-ready serverless system

⭐ If you found this project helpful, give it a star!

About

Serverless REST API using AWS Lambda, API Gateway, and DynamoDB for full CRUD functionality. Built with Python and tested using Postman. Scalable, event-driven, and cost-efficient.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages