From 8072bf4a8ee768d550e2fe07d896436c6b567c88 Mon Sep 17 00:00:00 2001 From: mythilias <43422292+mythilias@users.noreply.github.com> Date: Fri, 7 Jun 2024 13:06:40 -0500 Subject: [PATCH] Add files via upload --- integration-ddb-to-lambda/example.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 integration-ddb-to-lambda/example.java diff --git a/integration-ddb-to-lambda/example.java b/integration-ddb-to-lambda/example.java new file mode 100644 index 0000000..8bdcb42 --- /dev/null +++ b/integration-ddb-to-lambda/example.java @@ -0,0 +1,24 @@ +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; +import com.amazonaws.services.lambda.runtime.events.DynamodbEvent; +import com.amazonaws.services.lambda.runtime.events.DynamodbEvent.DynamodbStreamRecord; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +public class example implements RequestHandler { + + private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); + + @Override + public Void handleRequest(DynamodbEvent event, Context context) { + System.out.println(GSON.toJson(event)); + event.getRecords().forEach(this::logDynamoDBRecord); + return null; + } + + private void logDynamoDBRecord(DynamodbStreamRecord record) { + System.out.println(record.getEventID()); + System.out.println(record.getEventName()); + System.out.println("DynamoDB Record: " + GSON.toJson(record.getDynamodb())); + } +} \ No newline at end of file