Cody Ma
Cody Ma

Reputation: 347

How to write from DynamoDB to ElasticSearch using Lambda?

I've been going through this tutorial posted by amazon. On the step titled "Enabling the lambda blueprint", it references a dynamodb-to-elasticsearch blueprint. In my AWS console, there is no such blueprint. Does anybody know what the Python code for this blueprint looks like? Am I unable to see this because of my specific AWS account, or has AWS removed this?

Upvotes: 10

Views: 3200

Answers (1)

Alexander Patrikalakis
Alexander Patrikalakis

Reputation: 5205

You need to make sure a DynamoDB stream is enabled on your table including both old and new images. First, pull the DynamoDB stream record out of the Kinesis stream record. Then, determine whether the DynamoDB stream record represents an insertion, update or deletion. Third, delegate appropriately and upsert the corresponding document in ES for insertions and updates, and delete the corresponding document in ES for deletions.

For the time being, you can adapt the Python lambda handler shared here on Github - it parses stream records and writes documents to ES.

Upvotes: 1

Related Questions