D-Dᴙum
D-Dᴙum

Reputation: 7890

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.

Upvotes: 5

Views: 2484

Answers (3)

Telebh
Telebh

Reputation: 345

I have similar Issue, how to find new dependencies and versions that work for AWS JDK V2?

I used to use

<!--  original working fine with V1 -->
        <groupId>com.amazonaws</groupId> 
        <artifactId>aws-java-sdk-lambda</artifactId>
        <version>1.10.21</version> 

       <groupId>software.amazon.awssdk</groupId>
        <artifactId>lambda</artifactId>
        <version>2.16.60</version>          
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-lambda-java-core</artifactId>
         <version>1.1.0</version>
        
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-lambda-java-events</artifactId>
        <version>1.0.0</version>
    </dependency>
    
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-lambda-java-log4j</artifactId>
        <version>1.0.0</version>
     </dependency> 

what is the equivalent of these dependencies in AWS JDK V2 ( software.amazon.awssdk)?

Upvotes: -1

madhead
madhead

Reputation: 33374

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:

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.

Upvotes: 8

adiian
adiian

Reputation: 1392

From here:

Lambda supports two approaches for creating a handler:

  • Loading the handler method directly without having to implement an interface. This section describes this approach.

  • Implementing standard interfaces provided as part of aws-lambda-java-core library (interface approach). For more information, see Leveraging Predefined Interfaces for Creating Handler (Java).

Here is aws-lambda-java-core

Upvotes: 0

Related Questions