Category: AWS Toolkit for Eclipse*


AWS Toolkit for Eclipse: Locally Debug Your Lambda Functions and Amazon API Gateway Using AWS SAM Local

We are pleased to announce that the AWS Toolkit for Eclipse now supports AWS SAM Local for locally debugging your AWS Lambda functions and Amazon API Gateway in Java. See AWS SAM Local for more details about this command line tool.

Prerequisites

AWS SAM Local is dependent on a Lambda Docker image for running your Lambda functions locally. Before using this tool, you need to install Docker.

  1. Follow these instructions to install Docker and AWS SAM Local to your preferred OS platform.
  2. Follow these instructions to install and set up the AWS Toolkit for Eclipse.
  3. On the Preferences page in the AWS Toolkit for Eclipse, configure the SAM Local Executable path, as shown in the following screenshot. This enables the AWS Toolkit for Eclipse to know where to find your sam. Note, this step is only needed if you are not installing it to the default location.

Check out a sample SAM application from AWS CodeStar

Now let’s create a sample AWS CodeStar project by using the Java Spring template with AWS Lambda. See this tutorial for a complete walkthrough of how you can create an AWS CodeStar project in minutes.

After the project is created completely, check it out to your Eclipse IDE using the AWS Toolkit for Eclipse. You can take a look at this blogpost for details about how to use the AWS Toolkit for Eclipse to check out an AWS CodeStar project.

The following GIF video shows the process of checking out the project. You can also create a sample SAM application from the SAM blueprints that are provided in the AWS Toolkit for Eclipse. See this blogpost for details.

Debug the Lambda function and API Gateway locally

Now we have a sample SAM application, lambda-web, in our workspace. This project only has only one Lambda handler, HelloWorldHandler, which simply returns an API Gateway response. Let’s run this Lambda function in debug mode with a fake Amazon S3 event as input.

Let’s run this application in debug mode as API Gateway. In this mode, the Lambda function is triggered by the API Gateway request event. You can use your browser to trigger this event, as shown in the following GIF video.

Support

What do you think of this new feature? If you’re confused about any of the settings in the SAM Local launcher configuration page, see the User Guide for details.

If you find bugs while using this tool, or if you want to have more features added to this tool, please send us your thoughts in the GitHub issues repository. We’d like your feedback. Enjoy!