Skip to content

Commit

Permalink
Merge branch 'main' into maxday/add-linter
Browse files Browse the repository at this point in the history
  • Loading branch information
maxday authored Jul 29, 2024
2 parents cadd36b + aa399f5 commit 531fd4b
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 1 deletion.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ For information on how to optimize your functions watch the re:Invent talk [Opti

## Core Java Lambda interfaces - aws-lambda-java-core

[![Maven](https://img.shields.io/maven-central/v/com.amazonaws/aws-lambda-java-core.svg?label=Maven)](https://central.sonatype.com/artifact/com.amazonaws/aws-lambda-java-core)

This package defines the Lambda [Context](http://docs.aws.amazon.com/lambda/latest/dg/java-context-object.html) object
as well as [interfaces](http://docs.aws.amazon.com/lambda/latest/dg/java-handler-using-predefined-interfaces.html) that Lambda accepts.

Expand Down Expand Up @@ -47,6 +49,8 @@ public class HandlerStream implements RequestStreamHandler {

## Java objects of Lambda event sources - aws-lambda-java-events

[![Maven](https://img.shields.io/maven-central/v/com.amazonaws/aws-lambda-java-events.svg?label=Maven)](https://central.sonatype.com/artifact/com.amazonaws/aws-lambda-java-events)

This package defines [event sources](http://docs.aws.amazon.com/lambda/latest/dg/intro-invocation-modes.html) that Lambda natively accepts.
See the [documentation](aws-lambda-java-events/README.md) for a list of currently supported event sources.
Using this library you can have Java objects which represent event sources.
Expand Down Expand Up @@ -77,6 +81,8 @@ public class SqsHandler implements RequestHandler<SQSEvent, String> {

## Java Lambda JUnit Support - aws-lambda-java-tests

[![Maven](https://img.shields.io/maven-central/v/com.amazonaws/aws-lambda-java-tests.svg?label=Maven)](https://central.sonatype.com/artifact/com.amazonaws/aws-lambda-java-tests)

This package provides utils to ease Lambda Java testing. It uses the same Lambda serialisation logic and `aws-lambda-java-events` to inject events in your JUnit tests.

- [Release Notes](aws-lambda-java-tests/RELEASE.CHANGELOG.md)
Expand All @@ -100,6 +106,8 @@ public void testInjectSQSEvent(SQSEvent event) {

## aws-lambda-java-events-sdk-transformer

[![Maven](https://img.shields.io/maven-central/v/com.amazonaws/aws-lambda-java-events-sdk-transformer.svg?label=Maven)](https://central.sonatype.com/artifact/com.amazonaws/aws-lambda-java-events-sdk-transformer)

This package provides helper classes/methods to use alongside `aws-lambda-java-events` in order to transform
Lambda input event model objects into SDK-compatible output model objects.
See the [documentation](aws-lambda-java-events-sdk-transformer/README.md) for more information.
Expand All @@ -116,6 +124,8 @@ See the [documentation](aws-lambda-java-events-sdk-transformer/README.md) for mo

## Java Lambda Log4J2 support - aws-lambda-java-log4j2

[![Maven](https://img.shields.io/maven-central/v/com.amazonaws/aws-lambda-java-log4j2.svg?label=Maven)](https://central.sonatype.com/artifact/com.amazonaws/aws-lambda-java-log4j2)

This package defines the Lambda adapter to use with Log4J version 2.
See the [README](aws-lambda-java-log4j2/README.md) or the [official documentation](http://docs.aws.amazon.com/lambda/latest/dg/java-logging.html#java-wt-logging-using-log4j) for information on how to use the adapter.

Expand All @@ -130,6 +140,7 @@ See the [README](aws-lambda-java-log4j2/README.md) or the [official documentatio
```

## Java implementation of the Runtime Interface Client API - aws-lambda-java-runtime-interface-client
[![Maven](https://img.shields.io/maven-central/v/com.amazonaws/aws-lambda-java-runtime-interface-client.svg?label=Maven)](https://central.sonatype.com/artifact/com.amazonaws/aws-lambda-java-runtime-interface-client)

This package defines the Lambda Java Runtime Interface Client package, a Lambda Runtime component that starts the runtime and interacts with the Runtime API - i.e., it calls the API for invocation events, starts the function code, calls the API to return the response.
The purpose of this package is to allow developers to deploy their applications in Lambda under the form of Container Images. See the [README](aws-lambda-java-runtime-interface-client/README.md) for information on how to use the library.
Expand All @@ -146,6 +157,8 @@ The purpose of this package is to allow developers to deploy their applications

## Java Lambda provided serialization support - aws-lambda-java-serialization

[![Maven](https://img.shields.io/maven-central/v/com.amazonaws/aws-lambda-java-serialization.svg?label=Maven)](https://central.sonatype.com/artifact/com.amazonaws/aws-lambda-java-serialization)

This package defines the Lambda serialization logic using in the `aws-lambda-java-runtime-client` library. It has no current standalone usage.

- [Release Notes](aws-lambda-java-serialization/RELEASE.CHANGELOG.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.amazonaws.services.lambda.runtime.events;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;

/**
* Event to represent the payload which is sent to Lambda by S3 Batch to perform a custom
* action when using invocation schema version 2.0.
*
* https://docs.aws.amazon.com/AmazonS3/latest/dev/batch-ops-invoke-lambda.html
*/

@Data
@Builder(setterPrefix = "with")
@NoArgsConstructor
@AllArgsConstructor
public class S3BatchEventV2 {

private String invocationSchemaVersion;
private String invocationId;
private Job job;
private List<Task> tasks;

@Data
@Builder(setterPrefix = "with")
@NoArgsConstructor
@AllArgsConstructor
public static class Job {

private String id;
private Map<String, String> userArguments;
}

@Data
@Builder(setterPrefix = "with")
@NoArgsConstructor
@AllArgsConstructor
public static class Task {

private String taskId;
private String s3Key;
private String s3VersionId;
private String s3BucketName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,10 @@ public static S3BatchResponseBuilder fromS3BatchEvent(S3BatchEvent s3BatchEvent)
.withInvocationId(s3BatchEvent.getInvocationId())
.withInvocationSchemaVersion(s3BatchEvent.getInvocationSchemaVersion());
}
}

public static S3BatchResponseBuilder fromS3BatchEvent(S3BatchEventV2 s3BatchEvent) {
return S3BatchResponse.builder()
.withInvocationId(s3BatchEvent.getInvocationId())
.withInvocationSchemaVersion(s3BatchEvent.getInvocationSchemaVersion());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ public static S3Event loadS3Event(String filename) {
return loadEvent(filename, S3Event.class);
}

public static S3BatchEventV2 loadS3BatchEventV2(String filename) {
return loadEvent(filename, S3BatchEventV2.class);
}

public static SecretsManagerRotationEvent loadSecretsManagerRotationEvent(String filename) {
return loadEvent(filename, SecretsManagerRotationEvent.class);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.amazonaws.services.lambda.runtime.tests;

import com.amazonaws.services.lambda.runtime.events.S3BatchEventV2;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.*;

public class S3BatchEventV2Test {

@Test
public void testS3BatchEventV2() {
S3BatchEventV2 event = EventLoader.loadS3BatchEventV2("s3_batch_event_v2.json");
assertThat(event).isNotNull();
assertThat(event.getInvocationId()).isEqualTo("Jr3s8KZqYWRmaiBhc2RmdW9hZHNmZGpmaGFzbGtkaGZzatx7Ruy");
assertThat(event.getJob()).isNotNull();
assertThat(event.getJob().getUserArguments().get("MyDestinationBucket")).isEqualTo("destination-directory-bucket-name");
assertThat(event.getTasks()).hasSize(1);
assertThat(event.getTasks().get(0).getS3Key()).isEqualTo("s3objectkey");
}
}
21 changes: 21 additions & 0 deletions aws-lambda-java-tests/src/test/resources/s3_batch_event_v2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"invocationSchemaVersion": "2.0",
"invocationId": "Jr3s8KZqYWRmaiBhc2RmdW9hZHNmZGpmaGFzbGtkaGZzatx7Ruy",
"job": {
"id": "ry77cd60-61f6-4a2b-8a21-d07600c874gf",
"userArguments": {
"MyDestinationBucket": "destination-directory-bucket-name",
"MyDestinationBucketRegion": "us-east-1",
"MyDestinationPrefix": "copied/",
"MyDestinationObjectKeySuffix": "_new_suffix"
}
},
"tasks": [
{
"taskId": "y5R3a2lkZ29lc2hlurcS",
"s3Key": "s3objectkey",
"s3VersionId": null,
"s3Bucket": "source-directory-bucket-name"
}
]
}

0 comments on commit 531fd4b

Please sign in to comment.