4
votes

Please let me know if it is possible to debug Java AWS Lambda (serverless framework) in eclipse. Any pointers will be really helpful

3

3 Answers

1
votes

I know there are some interesting bespoke solutions that are being developed for live serverless debugging if you're prepared to leave Eclipse. Rookout is one example

0
votes

You'll want to take a look at AWS Sam. Basically you create a yaml file that runs your application, attach to the process, and use the Sam CLI to send events at your code.

From this github, you can see that a very simple yaml file is:

AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Description: A simple hello world Java 8 function
Resources:
  HelloWorld:
    Type: AWS::Serverless::Function
    Properties:
      Runtime: java8
      Handler: your.package.here.YourLambdaHandler
      CodeUri: ./target/your.jar
0
votes

I would assume you plan to debug it locally.

You need aws-sam-cli tool where a lambda could be run locally using sam local command.

sam local start-api -d 5858 and port 5858 will be used for debugging purposes. https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-debugging.html

Here an example how to do this with eclipse. https://docs.aws.amazon.com/toolkit-for-eclipse/v1/user-guide/tke-sam-local.html#debug-lam-function-locally