Skip to content

Commit

Permalink
reorganizes the es_session auth credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-McAdam committed Jun 19, 2020
1 parent 94735bc commit 93b05d6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
37 changes: 19 additions & 18 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions src/app/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@
region = os.environ["REGION"]
service = "es"

class ESConnection(AWSAuthConnection):
def __init__(self, region, **kwargs):
super(ESConnection, self).__init__(**kwargs)
self._set_auth_region_name(region)
self._set_auth_service_name("es")
session = boto3.Session()
credentials = session.get_credentials()

awsauth = AssumeRoleAWS4Auth(credentials, region, service)

es = Elasticsearch(
hosts=[host],
http_auth=awsauth,
use_ssl=True,
verify_certs=True,
connection_class=RequestsHttpConnection,
)

es = ESConnection(
region=region,
host=host,
is_secure=False)

# es = Elasticsearch()

Expand Down

0 comments on commit 93b05d6

Please sign in to comment.