Skip to content

Instantly share code, notes, and snippets.

@arbabnazar
Forked from jamesdavidson/es_ping.py
Created July 2, 2019 06:56
Show Gist options
  • Save arbabnazar/64d8c87d4ce53a46c26604f744bed08d to your computer and use it in GitHub Desktop.
Save arbabnazar/64d8c87d4ce53a46c26604f744bed08d 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment