How to use the aws-sdk.Kinesis function in aws-sdk

To help you get started, we’ve selected a few aws-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jacob-meacham / serverless-plugin-offline-kinesis-events / example / put_records.js View on Github external
import AWS from 'aws-sdk'
import BB from 'bluebird'
import fs from 'fs'
import winston from 'winston'
import yaml from 'js-yaml'

const readAsync = BB.promisify(fs.readFile)

winston.level = process.env.LAMBDA_LOG_LEVEL || 'info'

if (process.argv.length < 3) {
  winston.error(`usage: ${__filename.split('/').slice(-1)[0]} [file.yml]`)
  process.exit(1)
}

const kinesis = new AWS.Kinesis({
  endpoint: `${process.env.LAMBDA_KINESIS_HOST}:${process.env.LAMBDA_KINESIS_PORT}`,
  region: process.env.LAMBDA_REGION,
  apiVersion: '2013-12-02',
  sslEnabled: false
})

// Load the record
async function run() {
  // Read the records
  const records = await BB.all(process.argv.slice(2).map(f => readAsync(f)))
  // Write them to Kinesis
  return BB.map(records, record => kinesis.putRecord({
    Data: JSON.stringify(yaml.safeLoad(record)),
    PartitionKey: '0',
    StreamName: process.env.LAMBDA_KINESIS_STREAM_NAME
  }).promise())
github auth0 / kinesis-writable / test / buffer.tests.js View on Github external
const KinesisStream = require('../');
const AWS = require('aws-sdk');
const assert = require('chai').assert;
const sinon = require('sinon');

const _ = require('lodash');

const kinesis = new AWS.Kinesis({
  region: 'us-west-1'
});

const STREAM_NAME   = 'vagrant_testing';

function isPrioritaryMsg(entry) {
  return entry.level >= 40;
}

function get_iterator (callback) {
  
  var options = {
    StreamName: STREAM_NAME
  };

  kinesis.describeStream(options, function (err, stream) {
github nasa / cumulus / example / spec / helpers / kinesisHelpers.js View on Github external
async function createKinesisStream(streamName) {
  const kinesis = new Kinesis({ apiVersion: '2013-12-02', region: getRegion() });
  return pRetry(
    async () => {
      try {
        return kinesis.createStream({ StreamName: streamName, ShardCount: 1 }).promise();
      } catch (error) {
        if (error.code === 'LimitExceededException') throw new Error('Trigger retry');
        throw new pRetry.AbortError(error);
      }
    },
    {
      maxTimeout: 20000,
      onFailedAttempt: () => console.log('LimitExceededException when calling kinesis.createStream(), will retry.')
    }
  );
}
github DanteInc / js-cloud-native-cookbook / ch1 / event-stream / handler.js View on Github external
region: process.env.AWS_REGION,
    },
    ...event,
  }

  console.log('event: %j', e);

  const params = {
    StreamName: process.env.STREAM_NAME,
    PartitionKey: e.partitionKey,
    Data: Buffer.from(JSON.stringify(e)),
  };

  console.log('params: %j', params);

  const kinesis = new aws.Kinesis();

  kinesis.putRecord(params, callback);
};
github daniel-cottone / serverless-es-logs / templates / logProcesser.js View on Github external
new Promise((resolve, reject) => {
                let recordsReingestedSoFar = 0;
                for (let idx = 0; idx < putRecordBatches.length; idx++) {
                    const recordBatch = putRecordBatches[idx];
                    if (isSas) {
                        const client = new AWS.Kinesis({ region: region });
                        putRecordsToKinesisStream(streamName, recordBatch, client, resolve, reject, 0, 20);
                    } else {
                        const client = new AWS.Firehose({ region: region });
                        putRecordsToFirehoseStream(streamName, recordBatch, client, resolve, reject, 0, 20);
                    }
                    recordsReingestedSoFar += recordBatch.length;
                    console.log('Reingested %s/%s records out of %s in to %s stream', recordsReingestedSoFar, totalRecordsToBeReingested, event.records.length, streamName);
                }
            }).then(
              () => {
github erezrokah / serverless-monorepo-app / services / kinesis-service / src / kinesis.ts View on Github external
export const queueEvent = async (body: string | null) => {
  const kinesis = new Kinesis();

  let item = null;
  if (body) {
    try {
      const parsed = JSON.parse(body);
      item = parsed.record as IRecord;
    } catch (e) {
      console.log('Invalid body', e);
    }
  }

  if (item && isRecord(item)) {
    const record = { message: item.message, id: uuid() };
    const params = {
      Data: JSON.stringify({
        record,
github brain-power / Brain-Power-Amazon-Fidgetology / lambda / StreamResourceProvisioner / index.js View on Github external
function initServices() {
    aws.config.update({ region: process.env.AWS_REGION });
    rekognition = new aws.Rekognition();
    kinesisdata = new aws.Kinesis();
    kinesisvideo = new aws.KinesisVideo();
}
initServices();
github evansolomon / nodejs-kinesis-client-library / src / lib / aws / factory.ts View on Github external
export const createKinesisClient = (conf: ClientConfig, endpoint?: string): Kinesis => {
  const instance = new Kinesis(conf || {})
  if (endpoint) {
    instance.setEndpoint(endpoint)
  }

  return instance
}
github MoonMail / MoonMail / api / links / emailOpen / action.js View on Github external
import AWS from 'aws-sdk';
import omitEmpty from 'omit-empty';
import moment from 'moment';
import fs from 'fs';
import base64url from 'base64-url';
import { logger } from '../../lib/index';

const buffer = new AWS.Kinesis({ region: process.env.SERVERLESS_REGION });
const file = 'links/emailOpen/resources/open.gif';

export default function respond(event, context, cb) {
  logger().info('= emailOpen.action', JSON.stringify(event));

  const payload = omitEmpty({
    campaignId: event.campaignId,
    recipientId: event.recipientId,
    userId: event.userId ? base64url.decode(event.userId) : null,
    listId: event.listId,
    segmentId: event.segmentId,
    metadata: JSON.parse(event.headers),
    timestamp: moment().unix()
  });
  const params = {
    Data: JSON.stringify(payload),