Skip to main content

AWS Kinesis Firehose

Latest Version: 1.0.2

This library can be used to send data to an Amazon Web Services (AWS) Kinesis Firehose Delivery Stream. It depends upon the AWSRequestV4 library, which must be included too.

You can view the library’s source code on GitHub. Click here to see information on the available versions of this library.

To include this library in your project, add

#require "AWSRequestV4.class.nut:1.0.2"
#require "AWSKinesisFirehose.class.nut:1.0.2"

at the top of your agent code

Class Usage

Constructor: AWSKinesisFirehose(region, accessKeyID, secretAccessKey)

All parameters are strings. Your access keys can be generated with IAM.

Class Methods

putRecord(deliveryStreamName, data, userCallback)

Parameter Type Description
deliveryStreamName String Must be at least one and no more than 64 characters
data String or blob The actual data to be sent. Will be automatically base64-encoded
userCallback Function Callback function that takes one parameter: a response table

 
For information on how AWS responds to this method, see AWS documentation.

putRecordBatch(deliveryStreamName, dataArray, userCallback)

Parameter Type Description
deliveryStreamName String Must be at least one and no more than 64 characters
dataArray Array An array of data objects (each of which may be a string or blob)
userCallback Function Callback function that takes one parameter: a response table

 
For information on how AWS responds to this method, see AWS documentation.

Example

#require "AWSRequestV4.class.nut:1.0.2"
#require "AWSKinesisFirehose.class.nut:1.0.2"

const ACCESS_KEY_ID = "<YOUR_KEY_ID>";
const SECRET_ACCESS_KEY = "<YOUR_SECRET_ACCESS_KEY>";

firehose <- AWSKinesisFirehose("us-west-2", ACCESS_KEY_ID, SECRET_ACCESS_KEY);

// PutRecord
local data = {
  "someData": "look at all this data",
  "moreData": "wow!"
};
firehose.putRecord("myStreamName", http.jsonencode(data), function(response) {
    server.log(response.statuscode + ": " + response.body);
});

// PutRecordBatch
local data2 = "Data can be a string";
local data3 = blob();
data3.writestring("or a blob!");
local dataArray = [http.jsonencode(data), data2, data3];
firehose.putRecordBatch("myStreamName", dataArray, function(response) {
    server.log(response.statuscode + ": " + response.body);
});

Release History

The Electric Imp Dev Center documents the latest version of the library. For past versions, please see the Electric Imp public GitHub repos listed below.

Version Source Code Notes
1.0.0 GitHub Initial release
1.0.1 GitHub Minor code improvements
1.0.2 GitHub Force JSON 1.1 in requests to Firehose

License

The AWSKinesisFirehose library is licensed under the MIT License.