Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with RequestsHttpConnection #1920

Closed
GiovanniLeo opened this issue Feb 11, 2022 · 1 comment
Closed

Problem with RequestsHttpConnection #1920

GiovanniLeo opened this issue Feb 11, 2022 · 1 comment

Comments

@GiovanniLeo
Copy link

from elasticsearch import Elasticsearch, RequestsHttpConnection
from requests_aws4auth import AWS4Auth
from io import open


INDICES = []
#INDICES_USER = [] #Toremove

print(os.environ['ES_ENDPOINT'])
print(os.environ['AWS_ACCESS_KEY_ID'])
print(os.environ['AWS_SECRET_ACCESS_KEY'])
print(os.environ['AWS_SESSION_TOKEN'])

AWS_REGION = os.environ['AWS_DEFAULT_REGION']
ACCESS_KEY = os.environ['AWS_ACCESS_KEY_ID']
SECRET_KEY = os.environ['AWS_SECRET_ACCESS_KEY']
SESSION_TOKEN = os.environ['AWS_SESSION_TOKEN']

SERVICE = 'es'
awsauth = AWS4Auth(ACCESS_KEY, SECRET_KEY, AWS_REGION, SERVICE, session_token=SESSION_TOKEN)

es = Elasticsearch(
    hosts = [{'host': os.environ['ES_ENDPOINT'].replace("https://",""), 'port': 443}],
    http_auth = awsauth,
    use_ssl = True,
    verify_certs = True,
    connection_class = RequestsHttpConnection,
    timeout=30,
    retry_on_timeout=True,
    max_retries=10
)

Basically when I run that script I receive that error File "utils/post_deploy.py", line 7, in from elasticsearch import Elasticsearch, RequestsHttpConnection ImportError: cannot import name 'RequestsHttpConnection' from 'elasticsearch' (/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/elasticsearch/init.py).

I'm running this on AWS CodeBuild and the python version is 3.8

Thanks a lot!

@sethmlarson
Copy link
Contributor

sethmlarson commented Feb 11, 2022

Thanks for reporting this, we're tracking this issue here: #1778 Going to close this as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants