-
-
Save arbabnazar/64d8c87d4ce53a46c26604f744bed08d 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