Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing to Kinesis stream using AWS Lambda Function

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

like image 523
AKSHAY SHINGOTE Avatar asked Nov 20 '15 10:11

AKSHAY SHINGOTE


People also ask

Can Lambda write to Kinesis?

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

How do I send data to Kinesis streams?

To put data into the stream, you must specify the name of the stream, a partition key, and the data blob to be added to the stream. The partition key is used to determine which shard in the stream the data record is added to. All the data in the shard is sent to the same worker that is processing the shard.

Can Lambda write to Kinesis firehose?

Amazon Kinesis Data Firehose captures, transforms, and loads streaming data into downstream services such as Kinesis Data Analytics or Amazon S3. You can write Lambda functions to request additional, customized processing of the data before it is sent downstream.


1 Answers

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.

like image 50
Scott Wisniewski Avatar answered Nov 03 '22 19:11

Scott Wisniewski