I am new to AWS managed ES. I earlier worked on ES as local server. I am trying to build two-tier web app using the AWS JavaScript sdk (no Node.js). I have created an managed ES node, but not able to find out the way to connect for search and other add/update documents request. AWS SDK currently provides operation related classes and method but not for search and others. can some one help me to bridge this gap? I couldn't find any tutorial or sample code to connect for search operations?
2 Answers
Unfortunately, the SDK doesn't provide a way for you to do reads/writes. It's just done the basic way through HTTP requests but you should lock down your cluster.
This is a good blog post on how to lock down your cluster: https://aws.amazon.com/blogs/security/how-to-control-access-to-your-amazon-elasticsearch-service-domain/
So for example, you could setup an EC2 Instance and give the rights for the EC2 IP to access your elastic search cluster. Then, on the Elasticsearch page in AWS you should see an endpoint URL, just point your read/write requests to there, but lock it down to stay safe.
# Example write to Elasticsearch
curl -XPUT "https://yourESUrl.com/movies/movie/1" -d'
{
"title": "The Godfather",
"director": "Francis Ford Coppola",
"year": 1972
}'
If you need a brush up on the basics of Elasticsearch, check out this article.
In Node you can use the Requests module to do these commands if you like.

- 2,058
- 20
- 32
-
Thanks for this but i have actually seen all these and quite familiar with elasticsearch as well. Precisely, i am looking browser based (not node js) javascript search calls to AWS managed ES. right now trying to explore aws-js-sdk to create http calls and signing them. – Shahnaz Khan Jan 30 '17 at 03:40
-
Ah I understand better now :). That's definitely the right way to go – cameck Jan 30 '17 at 04:04
Elasticsearch.js is according to https://github.com/elastic/elasticsearch-js
The official low-level Elasticsearch client for Node.js and the browser.
You can use it from your browser to connect to classical Elasticsearch solution.
AWS Elasticsearch require you to sign your request. In node, you can use https://github.com/TheDeveloper/http-aws-es. It is written in ES6.
It is not your ideal solution but you can try to look at the source code to see how the connectors have been coded. https://github.com/TheDeveloper/http-aws-es/blob/master/connector-es6.js
By the way, is it not dangerous to expose your aws credential directly in your client ?

- 83
- 1
- 13
-
yes i found this connector and trying to create HTTPRequest but unfortunately hit another dead end, see [this](http://stackoverflow.com/questions/41928784/this-setuseragent-is-not-a-function-in-aws-sdk-2-8-0-js) question. I am login through AWS cognito and using the access key (not credentials). – Shahnaz Khan Jan 31 '17 at 07:09