Java 8 Lambda function with Eclipse IDE – chapter 1

Introduction

In this tutorial I will explain how to create a serverless api on amazon aws with lambda functions and the API gateway. The API is a create operation of an entity persisted on a RDS database instance (postgresql).

Environment

  • centos-release-6-10.el6.centos.12.3.x86_64 ( command:

rpm -q centos-release

  • openjdk version “1.8.0_191” 

java -version

  • Eclipse Java EE IDE for Web Developers. Version: Neon.3 Release (4.6.3) (Help->About Eclipse)
  • Amazon aws account (or IAM user with the appropriate policies) and the Access Keys

1 – eclipse plugin installation

First of all install the eclipse aws plugin. Go to Help->Install new software and write 

https://aws.amazon.com/eclipse

in the work with field.

Once the plugins appear, download only the selected options as per the following picture.

 

We are now ready to create a new lambda serverless project.

2 – configure the plugin

Go to window -> preferences and fill in the field Access Key ID and Secret access key you already have.

 

3 – Create a new project

Push the right mouse button in the project explorer tab and select New… Then on the New Project window select the following project:

And fill in the following form

The hello-world project is a standard project which simply 

4 – Upload the function to the lambda service

Right click on the project in the project explorer window then select Amazon Web Services-> Deploy Servless Project and fill in the following form with the appropriate content (AWS Region, S3 Bucket). 

5 test

If you like you can test the lambda function using the aws console. Simply go to

https://console.aws.amazon.com/lambda/

and select the lambda function we just created. The click on Configure test events

and fill in with the following data:

I will put an empty event here as no event are necessary to trigger our lambda.

We can then click “Test”. This will trigger lambda function execution and the following log will appear:

That’s all at the moment. See you in the next chapter.

 

Leave a Reply

Your email address will not be published. Required fields are marked *