Home > Software engineering >  How to use AWS serverless backend locally
How to use AWS serverless backend locally

Time:03-29

I joined a project which was half developed and I am trying to understand how to run the backend APIs locally.

So when a client hit a request it will go to AWS API Gateway goes to Lambda which then the lambda function which will get a response from the handler and send it back to the client.

I am still learning about this and not sure if it is written or not but I guess this is how the backend is working. But here comes the problem there is no script to run the backend locally for development there is only one deploy script in the package.json which is

#!/bin/bash
rm -rf node_modules/
yarn install --frozen-lockfile
SLS_DEBUG=* sls deploy -v

which is a bash script so is there any way to test this backend locally before actually deploying it every time i make changes.

CodePudding user response:

You could use Invoke Local to run the function locally before doing the sls deploy

CodePudding user response:

You should use serverless-offline to run serverless locally.

  1. npm i serverless-offline

  2. add serverless-offline in plugins of your serverless.yml file

    plugins:

    - serverless-offline
    
  3. then you can run it locally as serverless offline start

  • Related