An open API service indexing awesome lists of open source software.

https://github.com/priyam-hub/nodejs-serverless-aws

This project demonstrates a fully serverless backend application built with Node.js and the Serverless Framework. It provides RESTful APIs to perform CRUD Operations on Users table stored in Amazon DynamoDB. The APIs are deployed using AWS Lambda and API Gateway, making the solution highly scalable, cost-effective, and
https://github.com/priyam-hub/nodejs-serverless-aws

aws-apigateway aws-dynamodb aws-lambda aws-s3 javascript nodejs rest-api serverless-framework

Last synced: 2 months ago
JSON representation

This project demonstrates a fully serverless backend application built with Node.js and the Serverless Framework. It provides RESTful APIs to perform CRUD Operations on Users table stored in Amazon DynamoDB. The APIs are deployed using AWS Lambda and API Gateway, making the solution highly scalable, cost-effective, and

Awesome Lists containing this project

README

          



# ๐Ÿ› ๏ธ Serverless CRUD API using AWS Lambda, API Gateway & DynamoDB

This repository contains a **serverless backend application** built using **Node.js**, **AWS Lambda**, **API Gateway**, and **DynamoDB**. It demonstrates how to implement a scalable and cost-efficient REST API for user management โ€” including **Create**, **Read**, **Update**, and **Delete** (CRUD) operations โ€” using the **Serverless Framework**.


---

## ๐Ÿš€ Features

* Serverless architecture using AWS Lambda
* REST API endpoints via API Gateway
* DynamoDB for persistent NoSQL storage
* Clean and modular code (Node.js)
* IAM role-based access control
* Easily deployable using the Serverless Framework

---

## ๐Ÿ“ Project Structure

```
โ”œโ”€โ”€ handler.js # Lambda function logic for CRUD operations
โ”œโ”€โ”€ serverless.yml # Serverless framework configuration
โ”œโ”€โ”€ package.json # Node.js dependencies
โ””โ”€โ”€ README.md # Project documentation
```

---

## ๐Ÿงฉ Technologies Used

* **Node.js** (v18.x)
* **AWS Lambda**
* **Amazon API Gateway**
* **Amazon DynamoDB**
* **Serverless Framework**

---

## ๐Ÿ“ฆ Installation & Setup

### Prerequisites

* Node.js installed
* AWS CLI configured
* Serverless Framework installed globally

```bash
npm install -g serverless
```

### Steps

1. Clone the repository:

```bash
git clone https://github.com/your-username/serverless-dynamodb-crud.git
cd serverless-dynamodb-crud
```

2. Install dependencies:

```bash
npm install
```

3. Deploy to AWS:

```bash
serverless deploy
```

After deployment, the terminal will show the endpoint URLs for your APIs.

---

## ๐Ÿ“ฌ API Endpoints

| Method | Endpoint | Description |
| ------ | ------------------- | ----------------- |
| POST | `/create-user` | Create a new user |
| GET | `/get-users` | Get all users |
| PUT | `/update-user/{id}` | Update user by ID |
| DELETE | `/delete-user/{id}` | Delete user by ID |

**Note:** All requests and responses use `application/json` format.

---

## ๐Ÿ“˜ Sample Request Body

### POST `/create-user`

```json
{
"id": "123",
"name": "John Doe",
"email": "john@example.com"
}
```

### PUT `/update-user/{id}`

```json
{
"name": "Jane Doe",
"email": "jane@example.com"
}
```

---

## ๐Ÿ›ก IAM Role Requirements

Make sure the Lambda execution role has permission to access DynamoDB:

```yaml
Effect: Allow
Action:
- dynamodb:PutItem
- dynamodb:Scan
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: arn:aws:dynamodb:::table/Users
```

---

## ๐Ÿงน Clean Up

To remove all resources created:

```bash
serverless remove
```

---

## ๐Ÿ“„ License

This project is licensed under the MIT License.