Last active
October 28, 2019 05:50
-
-
Save jamesdavidson/9a53841a98842742fa650879a98f235b to your computer and use it in GitHub Desktop.
Ping Amazon Elasticsearch Service in Python3
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 characters
import sys | |
from elasticsearch import Elasticsearch, RequestsHttpConnection | |
from aws_requests_auth.boto_utils import BotoAWSRequestsAuth | |
# sanity check Python version | |
assert(sys.version_info >= (3,6)) | |
ES_ENDPOINT = 'search-dev-logs-kxsz2asdflkjlaksdfie7i36iry.ap-southeast-2.es.amazonaws.com' | |
AWS_REGION = 'ap-southeast-2' | |
# set up Elasticsearch client and check connectivity | |
auth = BotoAWSRequestsAuth(aws_host=ES_ENDPOINT, | |
aws_region=AWS_REGION, | |
aws_service='es') | |
es = Elasticsearch('https://'+ES_ENDPOINT, | |
connection_class=RequestsHttpConnection, | |
http_auth=auth) | |
assert(es.ping()) |
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 characters
boto3==1.9.4 | |
elasticsearch==6.3.1 | |
urllib3==1.23 | |
chardet==3.0.4 | |
certifi>=2018.8.24 | |
aws-requests-auth==0.4.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Amazon Elasticsearch and Elasticsearch offerred by Elastic are different. Elastic offers few versions that are ahead of Amazon, and they are more optimized for performance. You should specify that in your post in https://www.reddit.com/r/aws/comments/aenzxr/any_advice_on_using_aws_lambdas_to_stream/