Skip to content

Instantly share code, notes, and snippets.

@jamesdavidson
Last active October 28, 2019 05:50
Show Gist options
  • Save jamesdavidson/9a53841a98842742fa650879a98f235b to your computer and use it in GitHub Desktop.
Save jamesdavidson/9a53841a98842742fa650879a98f235b to your computer and use it in GitHub Desktop.
Ping Amazon Elasticsearch Service in Python3
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())
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
@kazizi-swe
Copy link

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment