Skip to content

Commit

Permalink
comments out and explains connection options local/live
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-McAdam committed Jun 22, 2020
1 parent 469cd85 commit 0e6c0e8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/app/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
region = os.environ["REGION"]
service = "es"


# There are two connection methods for connecting to the elasticsearch database
# 1. Running live inside aws elastic beanstalk
# - credentials are handled via instance roles attached to the ec2 instance
# 2. Running local for testing and development
# - credentials are handled via a token system with expiration, verified with your
# - individual access_key and secret_key configured through the awsebcli
# assure the appropriate connection method is uncommented


# *************************************************
# 1. Running live inside aws elastic beanstalk

# Elasticsearch connection method 1 BEGIN
class AssumeRoleAWS4Auth(AWS4Auth):
"""
Subclass of AWS4Auth which accepts botocore credentials as its first argument
Expand Down Expand Up @@ -71,7 +85,13 @@ def handle_date_mismatch(self, req):
verify_certs=True,
connection_class=RequestsHttpConnection,
)
# Elasticsearch connection method 1 END


# *************************************************
# 2. Running local for testing and development

# Elasticsearch connection method 2 BEGIN
# credentials = boto3.Session().get_credentials()
# awsauth = AWS4Auth(
# credentials.access_key,
Expand All @@ -88,6 +108,7 @@ def handle_date_mismatch(self, req):
# verify_certs=True,
# connection_class=RequestsHttpConnection,
# )
# Elasticsearch connection method 2 END


def logging_response(response):
Expand Down

0 comments on commit 0e6c0e8

Please sign in to comment.