diff --git a/complaint_search/es_interface.py b/complaint_search/es_interface.py index 48be4d8..8649cd6 100644 --- a/complaint_search/es_interface.py +++ b/complaint_search/es_interface.py @@ -6,8 +6,7 @@ from urllib.parse import quote from flags.state import flag_enabled -from opensearchpy import OpenSearch, RequestsHttpConnection, helpers -from requests_aws4auth import AWS4Auth +from opensearchpy import OpenSearch, helpers from complaint_search.defaults import ( CSV_ORDERED_HEADERS, @@ -36,11 +35,6 @@ _ES_PASSWORD = os.environ.get("ES_PASSWORD", "") _ES_INSTANCE = None -USE_AWS_ES = os.environ.get("USE_AWS_ES", False) -AWS_ES_ACCESS_KEY = os.environ.get("AWS_ES_ACCESS_KEY") -AWS_ES_SECRET_KEY = os.environ.get("AWS_ES_SECRET_KEY") -AWS_ES_HOST = os.environ.get("ES_HOST") - _COMPLAINT_ES_INDEX = os.environ.get("COMPLAINT_ES_INDEX", "complaint-index") @@ -144,30 +138,18 @@ def process_trends_response(response): def _get_es(): global _ES_INSTANCE if _ES_INSTANCE is None: - if USE_AWS_ES: # pragma: no cover - awsauth = AWS4Auth( - AWS_ES_ACCESS_KEY, AWS_ES_SECRET_KEY, "us-east-1", "es" - ) - _ES_INSTANCE = OpenSearch( - hosts=[{"host": AWS_ES_HOST, "port": 443}], - http_auth=awsauth, - use_ssl=True, - verify_certs=True, - connection_class=RequestsHttpConnection, - timeout=100, - ) - else: - host = _ES_HOST - if _ES_USER and _ES_PASSWORD: - encoded_username = quote(_ES_USER) - encoded_password = quote(_ES_PASSWORD) - host = f"{encoded_username}:{encoded_password}@{host}" - - _ES_INSTANCE = OpenSearch( - f"http://{host}:{_ES_PORT}", - use_ssl=(str(_ES_PORT) == "443"), - timeout=100 - ) + host = _ES_HOST + if _ES_USER and _ES_PASSWORD: + encoded_username = quote(_ES_USER) + encoded_password = quote(_ES_PASSWORD) + host = f"{encoded_username}:{encoded_password}@{host}" + + _ES_INSTANCE = OpenSearch( + f"http://{host}:{_ES_PORT}", + use_ssl=(str(_ES_PORT) == "443"), + timeout=100, + pool_maxsize=10 + ) return _ES_INSTANCE diff --git a/setup.py b/setup.py index 95c7f3c..b63c050 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,6 @@ def get_git_version(): "opensearch-py>=2.1.0,<=3.0.0", "django-localflavor>=4.0,<5.0", "django-flags>=5", - "requests-aws4auth", ] testing_extras = [ @@ -62,7 +61,6 @@ def get_git_version(): "deep==0.10", "deepdiff>=6.7,<7", "parameterized==0.9.0", - "requests-aws4auth", ]