Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 464
Cody Ma Avatar asked Dec 13 '16 01:12

Cody Ma


People also ask

Can Lambda read from DynamoDB?

With DynamoDB Streams, you can trigger a Lambda function to perform additional work each time a DynamoDB table is updated. Lambda reads records from the stream and invokes your function synchronously with an event that contains stream records.

Can Lambda write to DynamoDB?

AWS Lambda: Allows a Lambda function to access an Amazon DynamoDB table. This example shows how you might create an identity-based policy that allows read and write access to a specific Amazon DynamoDB table. The policy also allows writing log files to CloudWatch Logs.

Does Elasticsearch work with DynamoDB?

You can use DynamoDB as a durable store, Elasticsearch to extend its search capabilities, and Dynamo Streams to join them together.


1 Answers

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.

like image 149
Alexander Patrikalakis Avatar answered Sep 20 '22 17:09

Alexander Patrikalakis