AWS SAM: How to locally invoke all Node.js functions instead one by one?

  aws-lambda, aws-sam, docker, javascript, node.js

I am developing a REST API with AWS Lambda, API Gateway, RDS (MySQL). I am using Node.js. I am also using AWS SAM tool.

In my API I have lambda functions that accept URL parameters and that do not accept them.

I noticed that I can deploy these to AWS without an issue, and then execute from POSTMAN.

However when I try to locally run them, I am running into problems.

  1. When I execute sam local invoke, it says Error: You must provide a function logical ID when there are more than one functions in your template. So I had to execute them one by one, like sam local invoke FunctionName
  2. When I try to invoke a function that accepts URL parameters, it says TypeError: Cannot destructure property 'id' of 'event.queryStringParameters' as it is undefined. Here the id is the name of the URL Param.

So,

  1. How can I locally invoke all node.js functions, instead of one by one?
  2. How can I make sure that functions with URL Params also can be locally invoked?

Source: Docker Questions

LEAVE A COMMENT