I have an apiGateway endpoint and I am sending some post request to the endpoint. The integration type for the apigateway is lambda function. I want the lambda function to listen to the post data coming on the apigateway and push those data to kinesis firehose.
Can anyone help me get a sample node js lambda code that will push the incoming data to kinesis firehose. I tried to search for this but could not get anything.
Thanks
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.
You can attach a Lambda function to a Kinesis stream to process data. Multiple Lambda functions can consume from a single Kinesis stream for different kinds of processing independently. These can be used alongside other consumers such as Amazon Kinesis Data Firehose.
Kinesis Data Firehose can invoke your Lambda function to transform incoming source data and deliver the transformed data to destinations. You can enable Kinesis Data Firehose data transformation when you create your delivery stream.
I got it.
This is a sample code :
var AWS = require('aws-sdk');
var firehose = new AWS.Firehose();
exports.handler = function(event, context) {
var params = {
DeliveryStreamName: <STRING>,
Record: {
Data: decodeURIComponent(event)
}
};
firehose.putRecord(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
context.done();
});
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With