Git Product home page Git Product logo

nestjs-terraform-lambda's Introduction

NestJS + Terraform + AWS Lambda

Efficient NestJS for small API. Terraform with remote state setup for deploying to AWS Lambda.

Files and Folders

Folder Purpose
(root) API. Initialized with NestJS
./src/lambda.ts Entry point for AWS Lambda
./src/http-runnder.ts local development entry point
./infra IaC to AWS
./test E2E tests
./src NestJS TypeScript codes
./runners Local development utils

Ways of working

Local development

Use NestJS API for local development

  1. npm run start & npm run start:debug starts the NestJS API on localhost:3000
  2. Use npm run start:debug with VSCode Launcher Attach NestJS to debug using VS Code breakpoints
  3. runners/POST-zoo.rest - sample post requests
  4. runners/events - partial data taken from AWS Lambda cloudwatch. Can be used to invoke the src/lambda.ts-handler method

Deployment to AWS

Read the readme.md on ./infra.

Take note

  • Utilize lazy-loading module pattern to reduce startup time.
    • Study the src/domains examples. zoo is eagerly loaded while dogs and cats are lazy loaded.
    • src/factories/lazy-module.factory.ts simplifies the lazy-module initialization and caching.
  • Webpack is not advisable as per reason mentioned on ZenSoftware/bundled-nest

Lambda performance

... INFO #perf bootup time: 4.315s
... INFO #perf handler time: 61.218ms
... INFO #perf handler time: 0.761ms
... INFO #perf handler time: 0.668ms
... INFO #perf handler time: 0.749ms

References

https://docs.nestjs.com/faq/serverless#serverless

https://github.com/estevaodias/demo-terraform-nestjs-aws-lambda/tree/develop/ci

Special thanks to the authors

nestjs-terraform-lambda's People

Contributors

mjmaix avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.