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
+13-10Lines changed: 13 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,10 @@
1
-
# NestJS on AWS Lambda with CDK
1
+
# NestJS on AWS Lambda with AWS CDK
2
2
3
3
Reference implementation of a NestJS application running on AWS Lambda, using AWS CDK for infrastructure, HTTP API Gateway as the entry point, and GitHub Actions for CI/CD.
4
4
5
-
> Companion repository for the blog post **[A Practical Guide to Running Serverless NestJS on AWS Lambda with AWS CDK and GitHub Actions](https://deploy-preview-222--ajeetchaulagain.netlify.app/blog/nestjs-aws-serverless/)**.
5
+
> Companion repository for the blog post **[How to Deploy NestJS to AWS Lambda Using CDK and GitHub Actions](https://ajeetchaulagain.com/blog/nestjs-aws-lambda-cdk-deployment/)**.
6
+
7
+
> **Note:** The NestJS application itself is a default CLI scaffold that returns `Hello World!` from the root endpoint. The focus of this repository is the deployment setup, not the application code.
6
8
7
9
## Architecture
8
10
@@ -12,11 +14,12 @@ A client sends an HTTP request to API Gateway, which forwards it to the Lambda f
12
14
13
15
## Stack
14
16
15
-
-**Runtime:** Node.js 24 / NestJS
16
-
-**Infrastructure:** AWS CDK (TypeScript)
17
-
-**API:** HTTP API Gateway (v2)
18
-
-**Lambda Layer:** Production `node_modules` separated from application code
19
-
-**CI/CD:** GitHub Actions
17
+
-**Application:** NestJS (default scaffold, returns `Hello World!` from `/`)
18
+
-**Lambda runtime:** Node.js v20 and above — the handler uses `async/await` and works with any supported runtime. If you use `NODEJS_24_X`, note that the AWS Lambda Node.js 24 runtime dropped support for the callback-style handler, which is why this handler is written using `async/await`.
19
+
-**Infrastructure as code:** AWS CDK (TypeScript)
20
+
-**API:** HTTP API Gateway (v2) with Lambda proxy integration
21
+
-**Dependencies:** Production `node_modules` separated into a Lambda Layer
22
+
-**CI/CD:** GitHub Actions — deploys on push to `main` and on pull requests
20
23
21
24
## Project Structure
22
25
@@ -36,7 +39,7 @@ A client sends an HTTP request to API Gateway, which forwards it to the Lambda f
36
39
37
40
## Prerequisites
38
41
39
-
- Node.js 24
42
+
- Node.js 20 or 24
40
43
- AWS CLI configured (`aws configure`)
41
44
- AWS CDK bootstrapped in your target account/region (`cdk bootstrap`)
42
45
@@ -55,10 +58,10 @@ The application runs locally on `http://localhost:3000`.
55
58
56
59
## Build
57
60
58
-
Run the following before deploying:
61
+
CDK packages `dist/` and `layer/nodejs/node_modules/` as deployment assets at deploy time — both must be present before running `cdk deploy`. Neither is committed to the repository, so you need to generate them locally first:
59
62
60
63
```bash
61
-
#compile TypeScript → dist/
64
+
#Run nest production build → dist/
62
65
npm run build
63
66
64
67
# install production dependencies into layer/nodejs/node_modules/
0 commit comments