Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Java SDK Version For Creating a Lambda

I'm trying to develop an AWS Java lambda function by following the guidelines described here which describes the implementation of the RequestHandler interface and also references the AWS-lambda-java-core library. However, I am trying to use the latest SDK as recommended here but this is completely different and the RequestHandler interface doesn't appear to exist anymore.

It's not clear to me what is the name and version of the java libraries I need. Is there any guidance on all the different versions of the AWS java libraries there are and any updated examples? I have to admit I am completely confused by the AWS Java library versions and naming and don't entirely know which/what I need to add as a dependency just to create a simple AWS Lambda function in Java.

like image 814
D-Dᴙum Avatar asked Dec 02 '18 16:12

D-Dᴙum


1 Answers

However I am trying to use the latest SDK as recommended here but this is completely different and the RequestHandler interface doesn't appear to exist anymore.

You're using wrong a dependency. This is an SDK for using AWS Services via its REST API, like:

  • Putting an object to S3
  • Listing EC2 instances
  • Deleting an item from AWS DynamoDB
  • Invoking a Lambda

I.e. this is an SDK for working with various AWS services. It consists of many libraries, like aws-java-sdk-s3, aws-java-sdk-dynamodb. aws-java-sdk-lambda is one of them, but it is for interacting with Lambda API and not for authoring Lambdas.

The libraries you need for authoring Lambdas are:

  • com.amazonaws:aws-lambda-java-core
  • com.amazonaws:aws-lambda-java-events

As you see, those are different. First provides Handler interfaces you're looking for and second contains various events Lambda can accept as input: SNS events, CloudWatch timers and so on.

like image 78
madhead - StandWithUkraine Avatar answered Oct 03 '22 15:10

madhead - StandWithUkraine