GithubHelp home page GithubHelp logo

eastsun5566 / ddb-2-es Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 305 KB

๐Ÿšš Load streaming data into Amazon Elasticsearch from DynamoDB by Lambda with the latest ES bulk API

Home Page: https://npm.im/ddb-2-es

License: MIT License

TypeScript 100.00%
dynamodb elasticsearch lambda

ddb-2-es's Introduction

DynamoDB To Elasticsearch

NPM Version NPM Downloads License

๐Ÿšš Load streaming data into Amazon ES from DynamoDB by Lambda with latest ES bulk API

โœจ Installation

npm i ddb-2-es

# or yarn add ddb-2-es

๐Ÿš€ Usage

Basic

import { DynamoDBStreamHandler } from "aws-lambda";
import { ddb2es } from "ddb-2-es";

const { ES_DOMAIN, ES_INDEX } = process.env;

export const ddb2es: DynamoDBStreamHandler = async (event) => {
  console.log("Event:", JSON.stringify(event, null, 2));

  try {
    await ddb2es({
      // DDB stream event is required
      ddbStreamEvent: event,

      // ES endpoint is required
      esOptions: { node: `https://${ES_DOMAIN}` },

      // ES index is optional, default is DDB table name
      // (ES id is also optional, default is DDB table Keys join)
      forEachRecordToDocument: () => ({ index: ES_INDEX }),
    });
  } catch (err) {
    console.error("Error:", JSON.stringify(error, null, 2));

    throw error;
  }
};

export default ddb2es;

Customization

ddb2es({
  // Sometimes you want ES Doc index / id base on each stream record (DDB table item)
  forEachRecordToDocument: (record) => ({
    index: record.hashKey,
    id: record.rangeKey,
  }),
});

ddb-2-es's People

Contributors

dependabot[bot] avatar eastsun5566 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.