File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
integration-ddb-to-lambda Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change
1
+ import com .amazonaws .services .lambda .runtime .Context ;
2
+ import com .amazonaws .services .lambda .runtime .RequestHandler ;
3
+ import com .amazonaws .services .lambda .runtime .events .DynamodbEvent ;
4
+ import com .amazonaws .services .lambda .runtime .events .DynamodbEvent .DynamodbStreamRecord ;
5
+ import com .google .gson .Gson ;
6
+ import com .google .gson .GsonBuilder ;
7
+
8
+ public class example implements RequestHandler <DynamodbEvent , Void > {
9
+
10
+ private static final Gson GSON = new GsonBuilder ().setPrettyPrinting ().create ();
11
+
12
+ @ Override
13
+ public Void handleRequest (DynamodbEvent event , Context context ) {
14
+ System .out .println (GSON .toJson (event ));
15
+ event .getRecords ().forEach (this ::logDynamoDBRecord );
16
+ return null ;
17
+ }
18
+
19
+ private void logDynamoDBRecord (DynamodbStreamRecord record ) {
20
+ System .out .println (record .getEventID ());
21
+ System .out .println (record .getEventName ());
22
+ System .out .println ("DynamoDB Record: " + GSON .toJson (record .getDynamodb ()));
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments