i am writing a simple nodejs kinesis producer client which fails with no helpful information. Here's the code:
const { Kinesis, PutRecordsCommand } = require("@aws-sdk/client-kinesis");
const kinesis_client = new Kinesis({
region: 'us-east-1'
});
/**
*
* @param {*} streamName
*/
async function kinesis_pushdata() {
const params = {
StreamName: "course-progress",
Records: [
{
Data: JSON.stringify({
'record' : 'sample record'
}),
ParitionKey: 1
}
]
};
try {
const data = await kinesis_client.send(new PutRecordsCommand(params));
console.log(data);
} catch (error) {
console.log(error);
}
}
kinesis_pushdata();
Credentials are configured to be picked up from the config file. When i run this, i get a TypeError " TypeError: Cannot read property 'byteLength' of undefined " with not much clue on what's happening.
Any pointers will be very helpful.
thanks
AWS Kinesis expecting Data in following form
{
...
{
Data: Buffer.from( JSON.stringify({...}) )
}
}
Check the AWS document docs