简体   繁体   English

用于创建 Lambda 的 AWS Java SDK 版本

[英]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.我正在尝试按照此处描述的指南开发 AWS Java lambda 函数,该指南描述了RequestHandler接口的实现并引用了 AWS-lambda-java-core 库。 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.但是,我尝试使用此处推荐的最新 SDK,但这完全不同, RequestHandler接口似乎不再存在。

It's not clear to me what is the name and version of the java libraries I need.我不清楚我需要的 Java 库的名称和版本是什么。 Is there any guidance on all the different versions of the AWS java libraries there are and any updated examples?是否有关于所有不同版本的 AWS Java 库的指南以及任何更新的示例? 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.我不得不承认我对 AWS Java 库版本和命名完全感到困惑,并且不完全知道我需要添加哪些/什么作为依赖项,只是为了在 Java 中创建一个简单的 AWS Lambda 函数。

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.但是,我尝试使用此处推荐的最新 SDK,但这完全不同, RequestHandler接口似乎不再存在。

You're using wrong a dependency.您使用了错误的依赖项。 This is an SDK for using AWS Services via its REST API, like:这是一个通过其 REST API 使用 AWS 服务的开发工具包,例如:

  • Putting an object to S3将对象放入 S3
  • Listing EC2 instances列出 EC2 实例
  • Deleting an item from AWS DynamoDB从 AWS DynamoDB 中删除项目
  • Invoking a Lambda调用 Lambda

Ie this is an SDK for working with various AWS services.即这是一个用于处理各种 AWS 服务的 SDK。 It consists of many libraries, like aws-java-sdk-s3 , aws-java-sdk-dynamodb .它由许多库组成,例如aws-java-sdk-s3aws-java-sdk-dynamodb aws-java-sdk-lambda is one of them, but it is for interacting with Lambda API and not for authoring Lambdas. aws-java-sdk-lambda就是其中之一,但它用于与 Lambda API 交互,而不是用于编写 Lambda。

The libraries you need for authoring Lambdas are:创作 Lambda 所需的库是:

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 .首先提供您正在寻找的Handler接口,其次包含 Lambda 可以接受作为输入的各种事件:SNS 事件、CloudWatch 计时器

From here :这里

Lambda supports two approaches for creating a handler: Lambda 支持两种创建处理程序的方法:

  • 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).实现作为 aws-lambda-java-core 库的一部分提供的标准接口(接口方法)。 For more information, see Leveraging Predefined Interfaces for Creating Handler (Java).有关更多信息,请参阅利用预定义接口创建处理程序 (Java)。

Here is aws-lambda-java-core这是aws-lambda-java-core

I have similar Issue, how to find new dependencies and versions that work for AWS JDK V2?我有类似的问题,如何找到适用于 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)? AWS JDK V2 (software.amazon.awssdk) 中这些依赖项的等价物是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM