aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

How to debug Node Lambda using TypeScript

Open hoang-innomize opened this issue 6 years ago • 9 comments

Does anyone has successfully debug the Lambda function using TypeScript? If so, can you share configurations?

hoang-innomize avatar May 22 '19 08:05 hoang-innomize

I've just released https://github.com/buggy/aws-sam-webpack-plugin. It basically replaces the sam build step with Webpack.

buggy avatar Jul 15 '19 13:07 buggy

https://github.com/sthulb/cookiecutter-aws-sam-typescript/tree/master/%7B%7Bcookiecutter.project_name%7D%7D also has debugging configurations listed.

sriram-mv avatar Jul 15 '19 21:07 sriram-mv

Yeah, following the instruction from @heitorlessa now I am able to debug, but still looking for the configuration to debug inside the docker or something likes what we can do when using serverless framework

hoang-innomize avatar Jul 18 '19 09:07 hoang-innomize

@hoang-innomizetech I'm not sure what you mean by "the configuration to debug inside the docker or something likes what we can do when using serverless framework"?

@TheSriram The cookie cutter template has an example debugging configuration but you need to copy and modify it for each Lambda you create. My plugin automatically set them up by looking at your template.yaml. :)

buggy avatar Jul 19 '19 00:07 buggy

@buggy I means is right now we can only debug throw sam local invoke command, we cannot start a debug then send a request to Lambda from our application. I know that the serverless framework offline does not use docker so it is a different concept.

Since sam local start-api command allows specifying --debug-port and --debug-path parameters, it starts the Lambda function container in debug mode and exposes this port on the localhost (per instruction), then we can use attach configuration to start debugging. And then any request send to API that SAM exposes should able to debug without using sam local invoke command

hoang-innomize avatar Jul 19 '19 04:07 hoang-innomize

+1

dtelaroli avatar Jun 11 '20 02:06 dtelaroli

Did anyone find a way where you can debug lambda written in Typescript?

I tried to use @buggy webpack plugins, it did not work out of the box as I had to use a different launcher configuration than then one which the plugin generated. And it only worked for lambdas written in Javascript.

guoliang avatar Nov 19 '20 12:11 guoliang

Same here. I would like to know if anyone figured it out. I am writing a CDK code alongside few lambdas and trying to see if i can get debugging going locally for lambda code written in typescript

okonon avatar Nov 19 '20 15:11 okonon

Same here. I would like to know if anyone figured it out. I am writing a CDK code alongside few lambdas and trying to see if i can get debugging going locally for lambda code written in typescript

@okonon Are you using Windows or Linux? I'm asking if it could have something to do with OS, which is kind of unlikely but who knows? I'm using Windows 10 anyhow.

guoliang avatar Nov 19 '20 19:11 guoliang

Closing this particular issue as the underlying query has been answered, please feel free to re-open a new issue if that is not the case.

sriram-mv avatar Sep 27 '22 05:09 sriram-mv