Skip to content

Commit 8d8f430

Browse files
Update README.md
1 parent dbb3bda commit 8d8f430

1 file changed

Lines changed: 54 additions & 33 deletions

File tree

README.md

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -55,53 +55,74 @@ CREATE TABLE users (
5555
email VARCHAR(50) NOT NULL
5656
);
5757

58-
Setup Instructions
59-
1. AWS Infrastructure
60-
1. Create a VPC with private subnets for Lambda and RDS.
61-
2. Create Security Groups:
62-
RDS-SG: Allow inbound PostgreSQL (port 5432) from Lambda-SG.
63-
Lambda-SG: Allow outbound traffic to RDS.
64-
3. Launch Amazon RDS PostgreSQL in private subnets.
65-
4. Enable CloudWatch Logging for Lambda.
66-
2. Deploy Lambda Function
67-
1. Upload index.js (single file with all CRUD logic) to Lambda.
68-
2. Add environment variables (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME).
69-
3. Attach Lambda to the VPC and select correct subnets and security group.
70-
4. Assign IAM role with Lambda execution permissions.
71-
> Note: The Lambda file contains all CRUD logic. The handler routes requests based on HTTP method and path.
72-
3. Configure API Gateway
73-
1. Create a REST API (Regional, TLS 1.3).
74-
2. Add resources and methods:
75-
/users → GET, POST
76-
/users/{id} → GET, PUT, DELETE
77-
3. Enable Lambda Proxy Integration for all methods.
78-
4. Deploy API to a stage (e.g., dev) to generate the Invoke URL.
79-
4. Test API
80-
Use Postman or curl for testing.
81-
Create User (POST /users)
58+
## Setup Instructions
59+
60+
### **1. AWS Infrastructure**
61+
62+
1. **Create a VPC** with private subnets for Lambda and RDS.
63+
2. **Create Security Groups:**
64+
- **RDS-SG:** Allow inbound PostgreSQL (**port 5432**) from **Lambda-SG**.
65+
- **Lambda-SG:** Allow outbound traffic to RDS.
66+
3. **Launch Amazon RDS PostgreSQL** in private subnets.
67+
4. **Enable CloudWatch Logging** for Lambda.
68+
69+
### **2. Deploy Lambda Function**
70+
71+
1. **Upload `index.js`** (single file with all CRUD logic) to Lambda.
72+
2. Add **environment variables**: `DB_HOST`, `DB_USER`, `DB_PASSWORD`, `DB_NAME`.
73+
3. Attach Lambda to the **VPC** and select the correct subnets and security group.
74+
4. Assign **IAM role** with Lambda execution permissions.
75+
76+
> **Note:** The Lambda file contains all CRUD logic. The handler routes requests based on HTTP method and path.
77+
78+
### **3. Configure API Gateway**
79+
80+
1. Create a **REST API** (Regional, TLS 1.3).
81+
2. Add **resources and methods:**
82+
- `/users``GET`, `POST`
83+
- `/users/{id}``GET`, `PUT`, `DELETE`
84+
3. Enable **Lambda Proxy Integration** for all methods.
85+
4. Deploy API to a stage (e.g., `dev`) to generate the **Invoke URL**.
86+
87+
### **4. Test API Endpoints**
88+
89+
Use **Postman** or **curl** for testing:
90+
91+
**Create User (POST /users)**
92+
93+
```http
94+
POST https://<invoke-url>/users
95+
Content-Type: application/json
96+
97+
{
98+
"name": "Rabia",
99+
"email": "rabia@example.com"
100+
}
101+
102+
**Create User (POST /users)**
103+
```http
82104
POST https://<invoke-url>/users
83105
Body:
84106
{
85107
"name": "Rabia",
86108
"email": "rabia@example.com"
87109
}
88-
Get All Users (GET /users)
89-
GET https://<invoke-url>/users
90-
Get User by ID (GET /users/1)
91-
GET https://<invoke-url>/users/1
92-
Update User (PUT /users/1)
93-
PUT https://<invoke-url>/users/1
110+
**Get All Users (GET /users)**
111+
**GET https://<invoke-url>/users**
112+
**Get User by ID (GET /users/1)**
113+
**GET https://<invoke-url>/users/1**
114+
**Update User (PUT /users/1)**
115+
**PUT https://<invoke-url>/users/1**
94116
Body:
95117
{
96118
"name": "Rabia Updated",
97119
"email": "rabia.new@example.com"
98120
}
99-
Delete User (DELETE /users/1)
121+
**Delete User (DELETE /users/1)**
100122
DELETE https://<invoke-url>/users/1
101123
---
102-
Testing & Logging
124+
### Testing & Logging
103125
Use Postman or curl to test each endpoint.
104126
All Lambda executions are logged in CloudWatch, including request method, body, SQL queries, and errors.
105127

106-
Reply
107128

0 commit comments

Comments
 (0)