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