File tree Expand file tree Collapse file tree 2 files changed +39
-2
lines changed
integration-msk-to-lambda Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -691,12 +691,15 @@ serverless_connect_RDS_Lambda:
691691 languages :
692692 JavaScript :
693693 versions :
694- - sdk_version : 2
694+ - sdk_version : 3
695695 github : https://github.com/aws-samples/serverless-snippets/tree/main/lambda-function-connect-rds-iam
696696 excerpts :
697- - description : Connecting to an &RDS; database in a &LAM; function using Javascript .
697+ - description : Connecting to an &RDS; database in a &LAM; function using JavaScript .
698698 snippet_files :
699699 - lambda-function-connect-rds-iam/example.js
700+ - description : Connecting to an &RDS; database in a &LAM; function using TypeScript.
701+ snippet_files :
702+ - lambda-function-connect-rds-iam/example.ts
700703 Python :
701704 versions :
702705 - sdk_version : 3
@@ -748,3 +751,21 @@ serverless_connect_RDS_Lambda:
748751 services :
749752 lambda :
750753 rds :
754+ serverless_MSK_Lambda :
755+ title : Invoke a &LAM; function from an &MSK; trigger
756+ title_abbrev : Invoke a &LAM; function from an &MSK; trigger
757+ synopsis : implement a Lambda function that receives an event triggered by receiving records from
758+ an Amazon MSK cluster. The function retrieves the MSK payload and logs the record contents.
759+ category : Serverless examples
760+ languages :
761+ JavaScript :
762+ versions :
763+ - sdk_version : 3
764+ github : https://github.com/aws-samples/serverless-snippets/tree/main/integration-msk-to-lambda
765+ excerpts :
766+ - description : Consuming an &MSK; event with &LAM; using JavaScript.
767+ snippet_files :
768+ - integration-msk-to-lambda/example.js
769+ services :
770+ lambda :
771+ kafka :
Original file line number Diff line number Diff line change 1+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+ // SPDX-License-Identifier: Apache-2.0
3+
4+ exports . handler = async ( event ) => {
5+ // Iterate through keys
6+ for ( let key in event . records ) {
7+ console . log ( 'Key: ' , key )
8+ // Iterate through records
9+ event . records [ key ] . map ( ( record ) => {
10+ console . log ( 'Record: ' , record )
11+ // Decode base64
12+ const msg = Buffer . from ( record . value , 'base64' ) . toString ( )
13+ console . log ( 'Message:' , msg )
14+ } )
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments