我已经在 AWS Elasticsearch Service 中设置了 elasticsearch 域。它具有类似“ https://search-testelasticseach-xxxxxxxxxxxxxxxxxxx.us-east-2.es.amazonaws.com ”的端点。在该弹性搜索域中添加策略后,我正在尝试使用 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())