For the Java SDK V1, I have a lambda function like this:
public static void doSomethingLambda(S3Event s3Event) throws Exception {
s3Event....
however in SDK V2, S3Event
does not seem to exist. Unless I am using the wrong dependency? (The docs for V2 are pretty sparse)
Here is my SDK V1 Dependencies:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.11.534</version>
</dependency>
and SDK V2:
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>lambda</artifactId>
</dependency>
The AWS SDK for Java 2.0 is a rewrite of 1.0 with some great new features. As with version 1.0, it enables you to easily work with Amazon Web Services but also includes features like non-blocking IO and pluggable HTTP implementation to further customize your applications.
To integrate the latest version of an AWS SDK into your Lambda function's deployment package, create a Lambda layer, and then add it to your function. You can use either the AWS Command Line Interface (AWS CLI) or the Lambda console to create a Lambda layer and add it to your function.
You can run Java code in AWS Lambda. Lambda provides runtimes for Java that run your code to process events. Your code runs in an Amazon Linux environment that includes AWS credentials from an AWS Identity and Access Management (IAM) role that you manage. Lambda supports the following Java runtimes.
The Lambda API Reference provides information about each of the API methods, including details about the parameters in each API request and response. You can use Software Development Kits (SDKs), Integrated Development Environment (IDE) Toolkits, and command line tools to access the API.
According to the resolution provided on 18 May for aws lambda java libs to aws sdk java v2
aws-lambda-java-events version 3.0.0 was just released with support for all events (including S3) without the inclusion of SDK v1 dependencies.
This should help you make use of the AWS SDK for Java v2 and reduce your function package size as the v1 SDK does not need to be bundled anymore if it's not explicitly needed.
Source code is here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With