{"id":20031809,"url":"https://github.com/matrus2/dynamodb-stream-elasticsearch","last_synced_at":"2025-04-06T12:08:29.576Z","repository":{"id":31467090,"uuid":"125855899","full_name":"matrus2/dynamodb-stream-elasticsearch","owner":"matrus2","description":"Missing blueprint for AWS Lambda. Reads stream from AWS DynamoDB and writes it to ElasticSearch.","archived":false,"fork":false,"pushed_at":"2022-09-27T14:12:31.000Z","size":149,"stargazers_count":115,"open_issues_count":0,"forks_count":38,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T11:08:59.404Z","etag":null,"topics":["aws","aws-dynamodb","aws-elasticsearch","aws-lambda","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matrus2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-19T12:43:23.000Z","updated_at":"2024-02-16T04:02:47.000Z","dependencies_parsed_at":"2022-07-14T22:17:04.125Z","dependency_job_id":null,"html_url":"https://github.com/matrus2/dynamodb-stream-elasticsearch","commit_stats":null,"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrus2%2Fdynamodb-stream-elasticsearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrus2%2Fdynamodb-stream-elasticsearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrus2%2Fdynamodb-stream-elasticsearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrus2%2Fdynamodb-stream-elasticsearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matrus2","download_url":"https://codeload.github.com/matrus2/dynamodb-stream-elasticsearch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478322,"owners_count":20945266,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-dynamodb","aws-elasticsearch","aws-lambda","nodejs"],"created_at":"2024-11-13T09:34:48.066Z","updated_at":"2025-04-06T12:08:29.561Z","avatar_url":"https://github.com/matrus2.png","language":"JavaScript","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=8DRSB8GWY24R8\u0026source=url"],"categories":[],"sub_categories":[],"readme":"[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com)\n[![Build Status](https://app.travis-ci.com/matrus2/dynamodb-stream-elasticsearch.svg?branch=master)](https://app.travis-ci.com/matrus2/dynamodb-stream-elasticsearch)\n\n```\n             _                                   _  _     \n          __| | _  _  _ _   __ _  _ __   ___  __| || |__  \n         / _` || || || ' \\ / _` || '  \\ / _ \\/ _` || '_ \\\n         \\__,_| \\_, ||_||_|\\__,_||_|_|_|\\___/\\__,_||_.__/\n                |__/  _                                                     \n                  ___| |_  _ _  ___  __ _  _ __  \n                 (_-\u003c|  _|| '_|/ -_)/ _` || '  \\ \n                 /__/ \\__||_|  \\___|\\__,_||_|_|_|\n           _            _    _                              _    \n      ___ | | __ _  ___| |_ (_) __  ___ ___  __ _  _ _  __ | |_  \n     / -_)| |/ _` |(_-\u003c|  _|| |/ _|(_-\u003c/ -_)/ _` || '_|/ _|| ' \\ \n     \\___||_|\\__,_|/__/ \\__||_|\\__|/__/\\___|\\__,_||_|  \\__||_||_|\n                                                             \n                                                                            \n```\n# DynamoDB --\u003e Stream --\u003e Elasticsearch\n\nThe missing blueprint for AWS Lambda, which reads stream from AWS DynamoDB and writes it to Elasticsearch.\n\nWhenever 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:\n\n[Indexing Amazon DynamoDB Content with Amazon Elasticsearch Service Using AWS Lambda](https://aws.amazon.com/blogs/compute/indexing-amazon-dynamodb-content-with-amazon-elasticsearch-service-using-aws-lambda/) \n## Getting Started\n\nInstall:\n```bash\nnpm i dynamodb-stream-elasticsearch \n```\nUse it in your lambda:\n```javascript\nconst { pushStream } = require('dynamodb-stream-elasticsearch');\n\nconst { ES_ENDPOINT, INDEX } = process.env;\n\nfunction myHandler(event, context, callback) {\n  console.log('Received event:', JSON.stringify(event, null, 2));\n  pushStream({ event, endpoint: ES_ENDPOINT, index: INDEX })\n    .then(() =\u003e {\n      callback(null, `Successfully processed ${event.Records.length} records.`);\n    })\n    .catch((e) =\u003e {\n      callback(`Error ${e}`, null);\n    });\n}\n\nexports.handler = myHandler;\n```\nUpload Lambda to AWS and _star_ this repository if it works as expected!!\n\n### Parameters\n\n| Param  | Description | Required\n| ------------- | ------------- | ------------- |\n| event | Event object generated by the stream (pass it as it is and don't modify)  | required \n| endpoint  | Exact url of Elasticsearch instance (it works with AWS ES and standard ES) (string) | required\n| index  | The name of Elasticsearch index (string). If not provided will set the same as DynamoDB table name | optional\n| refresh  | Force Elasticsearch refresh its index immediately [more here](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html) (boolean). Default: true | optional\n| useBulk  | Enables bulk upserts and removals (boolean). Default: false | optional\n| keepAlive  | Keep sockets around in a pool to be used by other requests in the future (boolean). Default = false | optional\n| transformFunction  | A function/promise to transform each record before sending them to ES. Applies to INSERT and UPDATE operations. If transformFunction returns an empty object or false the row will be skipped. This function will receive `body` (NewImage), `oldBody` (OldImage) and (record) as the whole record as arguments. | optional\n| elasticSearchOptions  | Additional set of arguments passed to elasticsearch Client see [here](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/16.x/configuration.html#config-options) | optional\n\n\n## Running the tests\n\nTests are written using Mocha [https://mochajs.org/]. There are two sets of tests, one uses an elasticsearch instance and one uses localstack. To execute the former use:\n\n```bash\ndocker-compose up -d \nnpm test\n```   \n\nThe latter can be executed with additional setup in place. You will need to: \n\n```bash\ndocker-compose up -d\n# Install aws cli and configure it\npip install awscli-local\naws configure\naws --endpoint-url http://localhost:4566 es create-elasticsearch-domain --domain-name domain-test\nnpm run test-aws \n```\n\nOne Note: there seem to be problems running localstack on macs M1, to check if the cluster has been created run:\n```awslocal es describe-elasticsearch-domain --domain-name domain-test | grep Created```\n\n### Contributing\n\nIf you want to commit changes, make sure if follow these rules:\n1. All code changes should go with a proper integration test;\n2. Code should follow [Javascript Standard Guideline](https://standardjs.com/);\n3. Commit messages should be set according to [this article](https://chris.beams.io/posts/git-commit/).\n\n## Authors \u0026 Contributors\n\n* [matrus2](https://github.com/matrus2)\n* [aterreno](https://github.com/aterreno)\n* [cdelgadob](https://github.com/cdelgadob)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n\n## Donate\n\nIf you find this project to be useful and you would like to support the author for maintaining it, you might consider to make any donation under this link:\n\n[Donate via Paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=8DRSB8GWY24R8\u0026source=url)\n\n## Release notes:\nCompatible with node 8.10. (If for some reason you want to use it with node 6.10, then use 1.0.0 of this module)\n\nThird version doesn't support types as they were deprecated in ES 7.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrus2%2Fdynamodb-stream-elasticsearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatrus2%2Fdynamodb-stream-elasticsearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrus2%2Fdynamodb-stream-elasticsearch/lists"}