-
-
Save haandol/3dc1dae433afa6ed0225fa2f58b6486c to your computer and use it in GitHub Desktop.
Revisions
-
Simon Willison revised this gist
Mar 16, 2016 . 1 changed file with 32 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,4 +6,36 @@ The bad news: it's stuck on Elasticsearch 1.5.2 and dynamic scripting (Groovy) i http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-limits.html Authentication: the safest option is to create a brand new IAM user (using the tool at https://console.aws.amazon.com/iam/home?region=us-east-1 ) with its own access key and secret key. Then when you create the Elasticsearch instance you can paste in the following IAM string: arn:aws:iam::YOUR_AWS_ACCOUNT_ID:user/YOUR_IAM_USERNAME You'll need to look up YOUR_AWS_ACCOUNT_ID - http://docs.aws.amazon.com/IAM/latest/UserGuide/console_account-alias.html Having done all of the above, here's the secret recipe to getting Python to talk to your new Elasticsearch instance: import requests from requests_aws4auth import AWS4Auth endpoint = 'https://search-your-endpoint.us-east-1.es.amazonaws.com' auth=AWS4Auth(ACCESS_ID, ACCESS_SECRET, 'us-east-1', 'es') print requests.get(endpoint, auth=auth).json() print requests.get(endpoint + '/_aliases', auth=auth).json() # etc If you're using the official Python client for Elasticsearch, the recipe looks like this: from elasticsearch import Elasticsearch, RequestsHttpConnection from requests_aws4auth import AWS4Auth es = Elasticsearch( 'default', hosts=['search-your-endpoint.us-east-1.es.amazonaws.com'], http_auth=AWS4Auth(ACCESS_ID, ACCESS_SECRET, 'us-east-1', 'es'), use_ssl=True, verify_certs=True, connection_class=RequestsHttpConnection ) See also https://github.com/elastic/elasticsearch-py/issues/280 -
Simon Willison created this gist
Mar 16, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ # How to use Amazon AWS Elasticsearch The good news: you can get it running on the free tier (with a tiny instance). The bad news: it's stuck on Elasticsearch 1.5.2 and dynamic scripting (Groovy) is disabled. http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-limits.html