aws-sam-cli
aws-sam-cli copied to clipboard
How to debug Node Lambda using TypeScript
Does anyone has successfully debug the Lambda function using TypeScript? If so, can you share configurations?
I've just released https://github.com/buggy/aws-sam-webpack-plugin. It basically replaces the sam build step with Webpack.
https://github.com/sthulb/cookiecutter-aws-sam-typescript/tree/master/%7B%7Bcookiecutter.project_name%7D%7D also has debugging configurations listed.
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-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 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
+1
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.
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
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.
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.