I m using aws elasticsearch and i want to import data from dynamodb to elasticsearch,I don t want use river,Because Elasticsearch river API is deprecated, any Alternatives ?
-
You can use logstash to pull from DynamoDB into ES.Val– Val2015-12-03 17:08:47 +00:00Commented Dec 3, 2015 at 17:08
-
I don t want to use logstash output elasticsearch, i need logstash output dynamodb but this plugin doesn t exist.pho– pho2015-12-04 21:19:06 +00:00Commented Dec 4, 2015 at 21:19
-
Ok, so you should update your question which says "from dynamodb to elasticsearch", that's why I suggested a logstash dynamodb input.Val– Val2015-12-04 22:22:23 +00:00Commented Dec 4, 2015 at 22:22
2 Answers
I would enable dynamodb streams on your table and then write a lambda function which reads data from the stream and inserts it into elasticsearch. Amazon has a sample lambda function which streams data from kinesis to elasticsearch. It should be very easy to modify to work with a dynamodb stream.
1 Comment
I made it work with Python.
See a sample below which authenticate your Lambda function to ES. You can then use the ElasticSearch Python library.
from __future__ import print_function
import json
import boto3
from elasticsearch import Elasticsearch, RequestsHttpConnection
from requests_aws4auth import AWS4Auth
def lambda_handler(event, context):
session = boto3.session.Session()
credentials = session.get_credentials()
print(credentials.access_key)
print(credentials.secret_key)
print(credentials.token)
print(session.region_name)
awsauth = AWS4Auth(credentials.access_key,
credentials.secret_key,
session.region_name, 'es',
session_token=credentials.token)
es = Elasticsearch(
[ "YOUR ES ENDPOINT" ],
http_auth=awsauth,
use_ssl=True,
verify_certs=True,
connection_class=RequestsHttpConnection
)
print(es.info())
[...]
You need proper role for your Lambda function. I suggest reading this blog which is not fully updated but works for the IAM roles.
I which the Lambda Blueprint mentioned in the blog was still available but it is not at this time.
Hope this help