Amazon Web Services Firehose support for Node.js


Introduction

Amazon Data Firehoseexternal link is a fully managed service for delivering real-time streaming data to destinations such as Amazon S3, Amazon Redshift, Amazon OpenSearch Service, and HTTP endpoints.

Objects

Icon Description
NodeJS AWS Firehose Producer
NodeJS AWS Unknown Firehose Producer

Supported Libraries

The following libraries are supported:

Library Require Supported Producer APIs
AWS SDK V2 aws-sdk putRecord
putRecordBatch
AWS SDK V3 @aws-sdk/client-firehose PutRecordCommand
PutRecordBatchCommand

A NodeJS AWS Firehose Producer object is created for each call. The stream name is resolved from the DeliveryStreamName property of the parameters object. When the stream name cannot be resolved, a NodeJS AWS Unknown Firehose Producer object is created instead.

Examples

API V2

When analyzing the following source code:

const AWS = require("aws-sdk");

const firehose = new AWS.Firehose({ region: "us-east-1" });

const streamName = "my-delivery-stream";

const sendRecord = async () => {
  const params = {
    DeliveryStreamName: streamName,
    Record: { Data: JSON.stringify({ message: "test data" }) },
  };

  try {
    const data = await firehose.putRecord(params).promise();
    console.log("Success", data.RecordId);
  } catch (err) {
    console.error("Error", err);
  }
};

sendRecord();

a NodeJS AWS Firehose Producer object named my-delivery-stream is created with a callLink from sendRecord to it. If a matching Firehose Stream Delivery object is also present in the analysis, a callLink is created to it from the Producer as shown in the following snippet:

API V3

When analyzing the following source code:

const {FirehoseClient, PutRecordCommand } = require("@aws-sdk/client-firehose");

const client = new FirehoseClient({ region: "us-east-1" });

const streamName = "my-delivery-stream";

const sendRecord = async () => {
  const params = {
    DeliveryStreamName: streamName,
    Record: { Data: Buffer.from(JSON.stringify({ message: "test data" })) },
  };

  try {
    const data = await client.send(new PutRecordCommand(params));
    console.log("Success", data.RecordId);
  } catch (err) {
    console.error("Error", err);
  }
};

sendRecord();

a NodeJS AWS Firehose Producer object named my-delivery-stream is created with a callLink from sendRecord to it. If a matching Firehose Stream Delivery object is also present in the analysis, a callLink is created to it from the Producer as shown in the following snippet: