You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+93-49Lines changed: 93 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,26 +1,113 @@
1
1
# Project Overview
2
2
3
-
This repository deploys a Node.js WebAPI and a SQL Server database on AWS. It also includes a CI/CD pipeline using GitHub Actions to automate deployment of code changes to the API. The infrastructure is designed to be modular, scalable, and extendable for future enhancements. Lambda was used to host the Node.js WebAPI and the API Gateway exposes HTTP endpoints for the Lambda function
3
+
This repository deploys a Node.js WebAPI and a SQL Server database on AWS. It also includes a CI/CD pipeline using GitHub Actions to automate deployment of code changes to the API. The infrastructure is designed to be modular, scalable, and extendable for future enhancements. Lambda was used to host the Node.js WebAPI and the API Gateway exposes HTTP endpoints for the Lambda function.
6. Lambda connects to the RDS SQL Server using the credentials.
86
+
7. Lambda executes a test query:
87
+
8. API Gateway returns the JSON response to the client.
88
+
89
+
## API Routes
90
+
91
+
Client
92
+
│
93
+
├─ GET / ──► API Gateway ──► Lambda ──► Returns Welcome Message
94
+
│
95
+
└─ GET /health ──► API Gateway ──► Lambda ──► Connects to RDS ──► Returns DB Status
96
+
97
+
## How code changes are deployed (CI/CD workflow)
98
+
99
+
When application code is modified and pushed to GitHub, the CI/CD pipeline automatically updates the Lambda function with the latest version of the code. The process works as follows:
100
+
101
+
1. A code change is pushed to the GitHub repository.
102
+
- A GitHub Actions workflow is triggered.
103
+
2. Installs Node.js
104
+
- Installs project dependencies
105
+
3. Builds a new deployment.zip file containing the Lambda application code
106
+
4. The pipeline uploads the new ZIP file to the S3 bucket that was created by Terraform during initial setup.
107
+
5. After the ZIP is uploaded, the workflow calls AWS to update the Lambda function’s code, instructing Lambda to pull the latest ZIP from S3.
108
+
6. Lambda immediately switches to the new code, meaning all API Gateway requests (`/` and `/health`) begin using the updated Lambda logic without any downtime.
109
+
110
+
24
111
# Getting Started
25
112
26
113
## Prerequisites
@@ -42,26 +129,6 @@ Default region name [None]: your region
42
129
Default output format [None]:
43
130
```
44
131
45
-
## Clone Repository
46
-
47
-
```bash
48
-
git clone <repository-url>
49
-
```
50
-
51
-
52
-
## Lambda Deployment zip
53
-
54
-
`Install dependencies locally:`
55
-
56
-
```bash
57
-
npm install
58
-
```
59
-
60
-
`Zip the application code and node_modules:`
61
-
62
-
```bash
63
-
zip -r deployment.zip .
64
-
```
65
132
66
133
# Terraform Infrastructure
67
134
@@ -101,26 +168,3 @@ serverless/
101
168
```
102
169
103
170
104
-
# Services
105
-
106
-
107
-
-**AWS Lambda**: A serverless compute service used to host the Node.js WebAPI. Lambda allows the application to run without provisioning or managing servers. It automatically scales based on traffic, and you only pay for the compute time consumed by your code.
108
-
-**API Gateway v2 (HTTP API)**: Exposes HTTP endpoints for the Lambda function, enabling clients to interact with the WebAPI. API Gateway handles routing, request validation, and security, providing a managed entry point for the API.
109
-
-**Amazon RDS (SQL Server)**: A fully managed relational database service used to store the application’s data. The SQL Server instance is provisioned with standard compute (`db.t3.medium`) and includes automated backups, monitoring, and maintenance. It is easily upgradable for future performance or availability requirements.
110
-
-**Terraform**: An Infrastructure-as-Code (IaC) tool used to define, provision, and manage AWS resources declaratively. Terraform ensures that the infrastructure is reproducible, version-controlled, and can be modified or extended with minimal effort.
111
-
-**GitHub Actions**: Provides the CI/CD pipeline to automatically build, test, and deploy changes to the Node.js WebAPI. When code is pushed to the main branch, the workflow packages the Lambda function, runs tests, and deploys the code to AWS, ensuring fast and reliable updates.
112
-
-**IAM Roles**:
113
-
-**AWS Secrets Manager**:
114
-
-**Security Group**:
115
-
-**CloudWatch**:
116
-
117
-
118
-
# Workflow Summary
119
-
120
-
A user accesses the API using a URL. The API Gateway recieves the HTTP request. It determines which route matches ( / or /health). The request is forwaded to the configured AWS Lambda Function. Lambda is invoked with an event payload containing details such as path and method. The function inspects the request path and decides which logic to run. Lambda reads database configuration values (DB host, username, password, name and port) from its environmental variable which are set in Terraform. Lambda attempts to connect to the SQL server instance in Amazon RDS. Lambda runs a SQL query and if successful, Lambda confirms the database is reachable. Lambda reutrns a structured JSON response:
121
-
122
-
/ returns a welcome message + timestamp
123
-
124
-
/health returns API status, timestamp and database connection status
125
-
126
-
Then API Gateway converts the Lambda response into a standard HTTP response. The user recieves the final JSON output.
0 commit comments