All Projects → jacob-meacham → serverless-plugin-offline-kinesis-events

jacob-meacham / serverless-plugin-offline-kinesis-events

Licence: MIT license
⚡ Serverless plugin that works with serverless-offline to allow offline testing of Serverless functions that are triggered by Kinesis events.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to serverless-plugin-offline-kinesis-events

Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (+240%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Jest Plugin
Plugin for Serverless Framework which adds support for test-driven development using Jest
Stars: ✭ 111 (+640%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Reqvalidator Plugin
Serverless plugin to attach AWS API Gateway Basic Request Validation https://rafpe.ninja/2017/12/18/serverless-own-plugin-to-attach-aws-api-gateway-basic-request-validation/
Stars: ✭ 59 (+293.33%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Step Functions
AWS Step Functions plugin for Serverless Framework ⚡️
Stars: ✭ 758 (+4953.33%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Mocha Plugin
Plugin for Serverless Framework which adds support for test-driven development using Mocha
Stars: ✭ 152 (+913.33%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Appsync Plugin
serverless plugin for appsync
Stars: ✭ 804 (+5260%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Api Gateway Caching
A plugin for the Serverless framework which helps with configuring caching for API Gateway endpoints.
Stars: ✭ 92 (+513.33%)
Mutual labels:  serverless-framework, serverless-plugin
serverless-rack
Serverless plugin to deploy Ruby Rack applications (Sinatra/Rails/Padrino/Cuba etc.) and bundle gems
Stars: ✭ 58 (+286.67%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Sentry Plugin
This plugin adds automatic forwarding of errors and exceptions to Sentry (https://sentry.io) and Serverless (https://serverless.com)
Stars: ✭ 146 (+873.33%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Openwhisk
Adds Apache OpenWhisk support to the Serverless Framework!
Stars: ✭ 131 (+773.33%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Plugin Typescript
Serverless plugin for zero-config Typescript support
Stars: ✭ 611 (+3973.33%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Chrome
🌐 Run headless Chrome/Chromium on AWS Lambda
Stars: ✭ 2,625 (+17400%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Wsgi
Serverless plugin to deploy WSGI applications (Flask/Django/Pyramid etc.) and bundle Python packages
Stars: ✭ 377 (+2413.33%)
Mutual labels:  serverless-framework, serverless-plugin
Plugins
Serverless Plugins – Extend the Serverless Framework with these community driven plugins –
Stars: ✭ 850 (+5566.67%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Plugin Canary Deployments
Canary deployments for your Serverless application
Stars: ✭ 283 (+1786.67%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Plugin Git Variables
⚡️ Expose git variables to serverless
Stars: ✭ 75 (+400%)
Mutual labels:  serverless-framework, serverless-plugin
serverless-plugin-epsagon
Epsagon's plugin for Serverless Framework ⚡️
Stars: ✭ 53 (+253.33%)
Mutual labels:  serverless-framework, serverless-plugin
serverless-dynamodb-ttl
⚡️ Serverless Plugin to set DynamoDB TTL
Stars: ✭ 16 (+6.67%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Kms Secrets
🔑🔐☁️ Serverless plugin to encrypt variables with KMS (DEPRECATED)
Stars: ✭ 116 (+673.33%)
Mutual labels:  serverless-framework, serverless-plugin
Awesome Serverless
DEPRECATED: Curated list of resources related to serverless computing and serverless architectures.
Stars: ✭ 2,049 (+13560%)
Mutual labels:  serverless-framework, serverless-plugin

serverless-plugin-offline-kinesis-events

serverless Build Status

This plugin works with serverless-offline to allow offline testing of serverless functions that are triggered by Kinesis events.

Quickstart

First, start Kinesalite: docker run --rm -d -p 4567:4567 dlsniper/kinesalite:1.11.4

Then, populate Kinesalite with the appropriate streams (we add a bootstrap command for this):

async function ensureStream() {
  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
  })
  try {
    // Create the stream
    await kinesis.createStream({ ShardCount: 1, StreamName: process.env.LAMBDA_KINESIS_STREAM_NAME }).promise()
  } catch (err) {
    if (err.code === 'ResourceInUseException') {
      // Stream already exists, so no problem
      winston.info('Kinesis stream already exists')
      return
    }
    throw err
  }
}

Start your service: sls offline

Finally, put records to Kinesalite (this script loads the yml to put from the first command line argument):

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(1).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())
}

run()
  .then(() => winston.info('Put records successfully'))
  .catch((err) => {
    winston.error(`Failed with error ${err.stack}`)
    process.exit(2)
  })

And you'll see your lambda fire!

Usage in the real world

See the example/ folder for how we've used this plugin successfully in the real world.

Release Notes

  • 1.1.1 - Fix issue that didn't allow for both serverless-offline http events and kinesis events to be used at the same time.
  • 1.1.0 - Allow plugin to work either with serverless-webpack or without
  • 1.0.1 - Fix example, fix compatibility issue with serverless-offline
  • 1.0.0 - Initial release

Contributors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].