Skip to content

Conversation

@carlzogh
Copy link
Contributor

Description of changes:
This change adds a new library aws-lambda-java-events-transformer to the collection.

Extract from Readme:

About

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 (eg. DynamodbEvent to a List of records writable back to DynamoDB through the AWS DynamoDB SDK v2).

Getting started

Add the following Apache Maven dependencies to your pom.xml file:

<dependencies>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-lambda-java-events-sdk-transformer</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-lambda-java-events</artifactId>
        <version>2.2.8</version>
    </dependency>
</dependencies>

To use this library as a transformer to the AWS DynamoDB Java SDK v2, also add the following dependencies to your pom.xml file:

<dependencies>
    <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>dynamodb</artifactId>
        <version>2.11.12</version>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-dynamodb</artifactId>
        <version>1.11.163</version>
    </dependency>
</dependencies>

Note that because aws-lambda-java-events version 2 requires the DynamoDB v1 SDK, this is also required for this library.

Example Usage

To convert a full DynamodbEvent object to an SDK v2 compatible List<Record>:

import com.amazonaws.services.lambda.runtime.events.transformers.DynamodbEventTransformer;
public class DDBEventProcessor implements RequestHandler<DynamodbEvent, String> {
    public String handleRequest(DynamodbEvent ddbEvent, Context context) {
        // Process input event
        List<Record> convertedRecords = DynamodbEventTransformer.toRecordsV2(ddbEvent);
        // Modify records as needed and write back to DynamoDB using the DynamoDB AWS SDK for Java 2.0
    }
}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@carlzogh carlzogh merged commit c05d2a3 into aws:master May 5, 2020
raupachz pushed a commit to raupachz/aws-lambda-java-libs that referenced this pull request Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants