Writing to Kinesis stream using AWS Lambda Function

AKSHAY SHINGOTE picture AKSHAY SHINGOTE · Nov 20, 2015 · Viewed 11.4k times · Source

Can we create a Lambda function like which can get executed when we write a record to Dynamo DB table & that record is written to Kinesis stream ?? Basically can we write to Kinesis stream using Lambda function?? If yes please share sample code for that..Also I want to know how does that work.....Thank You

Answer

Scott Wisniewski picture Scott Wisniewski · Nov 21, 2015

Yes. You can create a Dynamo Trigger backed by a Lambda function, and have that Lambda Function write to a stream.

Here is a walk through that shows how to create a trigger:

http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.Lambda.html

In the body of your Lambda function you can then call the Kinesis "putRecord" function. Here's info on "putRecord":

http://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecord.html

If you are implementing your Lambda function in Node.js, here's a link to the SDK docs for Kinesis:

http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Kinesis.html#putRecord-property

Similarly here is a link for the Java SDK (if you are using java):

http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/kinesis/AmazonKinesis.html#putRecord(com.amazonaws.services.kinesis.model.PutRecordRequest)

And a link to the Boto docs (if you are using python):

http://boto.cloudhackers.com/en/latest/ref/kinesis.html

The doc links should have all the info your need.