1.1.8 • Published 5 years ago

elasticcloud-dynamodb-stream v1.1.8

Weekly downloads
4
License
ISC
Repository
-
Last release
5 years ago

js-standard-style

    Basically a fork of https://github.com/matrus2/dynamodb-stream-elasticsearch                  

Works only with the standard Elasticsearch >= 7.2

DynamoDB --> Stream --> ElasticSearch

The missing blueprint for AWS Lambda, which reads stream from AWS DynamoDB and writes it to ElasticSearch. Compatible with node 10.x.

Whenever data is changed (modified, removed or inserted) in DynamoDB one can use AWS Lambda function to capture this change and update ElasticSearch machine immediately. Further reading:

Getting Started

Install:

npm install --save elasticcloud-dynamodb-stream 

Use it in your lambda:

const {pushStream} = require("elasticcloud-dynamodb-stream")

const trans = async (obj) => {
    // do stuff with obj
    return obj
}

const ES_ARGS = {
  index: process.env.INDEX, 
  host: process.env.ES_ENDPOINT,
  transformFunction: trans, // OPTIONAL
  refresh: false
}

module.exports.toElastic = async (event, context) => {
    try {
      await pushStream({ event,  ...ES_ARGS})
    } catch(e) {
      console.log(e)
      throw e
    }
    return  `Successfully processed ${event.Records.length} records.`
}

Parameters

ParamDescriptionRequired
eventEvent object generated by the stream (pass it as it is and don't modify)required
endpointExact url of ElasticSearch instance (it works only with standard ES) (string)required
indexThe name of ElasticSearch index (string). If not provided will set the same as DynamoDB table nameoptional
refreshForce ElasticSearch refresh its index immediately more here (boolean). Default: trueoptional
transformFunctionA function/promise to transform each record before sending them to ES. Applies to INSERT and UPDATE operationsoptional
optionsAdditional set of arguments passed to elasticsearch Client see hereoptional

Authors & Contributors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago