This project was cloned from the nestjs-starter-rest-api repository.
Please refer to the project's starter-kit's README file to understand more about the project's business logic, etc.
This README that you are viewing now talks more about how to deploy the project on AWS Lambda.
- nestjs-starter-rest-api - NestJS Starter-Kit for REST API.
- Serverless Framework - Build applications with serverless architectures using AWS Lambda.
# Project Dependencies:
$ npm install
# Serverless Framework:
npm install -g serverlessWe need the various required environment variables to exist in order to run the app.
Create a .env file from the template .env.template file. For more details, please refer to the starter-kit's README file.
To run the app we need this pre-requisite:
- MySQL server running
Commands:
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod$ npm run sls-offlineWe need the various required environment variables to exist in order to run the app.
We currently hard-code them in the serverless.yml file. Our recommended way is to use AWS SSM - Parameter Store and point to the SSM variable path in the serverless.yml file.
# deploy to DEV environment
npm run deploy:devUsually when we use the serverless deploy command, the framework runs serverless package in the background first, and then deploys the generated package(Lamda packages are zip files) via CloudFormation.
But as of Dec 2020, AWS Lambda allows us to package it with a Docker container image that can be up to 10 GB in size, instead of traditional zip files. That means we can have a Dockerfile with all the dependencies, push it to ECR, and just point Lambda to the AWS ECR image.
You can avail docker support with the help of serverless framework also instead of creating it manually process. Read here for more detailed steps where you start off by changing in the serverless.yml file.
