AWS Elasticsearch Service で Elasticsearch ドメインをセットアップしました。「 https://search-testelasticseach-xxxxxxxxxxxxxxxxxxx.us-east-2.es.amazonaws.com 」のようなエンドポイントがあります。その Elasticsearch ドメインにポリシーを追加した後、IAM ユーザーを使用して AWS Elasticsearch ドメイン エンドポイントに接続しようとしています。
エラーは言う
"Max retries exceeded with url: //search-testelasticseach-XXXXXXXXXXXXXXX.us-east-2.es.amazonaws.com:443/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x105111d68>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))) caused by: ConnectionError(HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //search-testelasticseach-pkpbravqd4djbi3kjtihsra5ma.us-east-2.es.amazonaws.com:443/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x105111d68>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known')))"
コードスニペット:
from elasticsearch import Elasticsearch, RequestsHttpConnection
from requests_aws4auth import AWS4Auth
YOUR_ACCESS_KEY = "XXX"
YOUR_SECRET_KEY = "XXXX"
REGION = "us-east-2"
host = 'https://search-testelasticseach-XXX.us-east-2.es.amazonaws.com'
awsauth = AWS4Auth(YOUR_ACCESS_KEY, YOUR_SECRET_KEY, REGION, 'es')
es = Elasticsearch(
hosts=[{'host': host, 'port': 443}],
http_auth=awsauth,
use_ssl=True,
verify_certs=True,
connection_class=RequestsHttpConnection
)
print(es.info())