Skip to content

Commit

Permalink
[PRMP-1287] add logs for debugging edge lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
NogaNHS committed Dec 17, 2024
1 parent f7a6b2b commit 8c232c9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
23 changes: 13 additions & 10 deletions lambdas/handlers/edge_presign_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@
@handle_edge_exceptions
@validate_s3_request
def lambda_handler(event, context):
request: dict = event["Records"][0]["cf"]["request"]
logger.info("Edge received S3 request")
try:
request: dict = event["Records"][0]["cf"]["request"]
logger.info("Edge received S3 request")

edge_presign_service = EdgePresignService()
request_values: dict = edge_presign_service.filter_request_values(request)
edge_presign_service.use_presign(request_values)
edge_presign_service = EdgePresignService()
request_values: dict = edge_presign_service.filter_request_values(request)
edge_presign_service.use_presign(request_values)

forwarded_request: dict = edge_presign_service.update_s3_headers(
request, request_values
)
forwarded_request: dict = edge_presign_service.update_s3_headers(
request, request_values
)

logger.info("Edge forwarding S3 request")
return forwarded_request
logger.info("Edge forwarding S3 request")
return forwarded_request
except Exception as e:
logger.error(e)
3 changes: 1 addition & 2 deletions lambdas/requirements/requirements_edge_lambda.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ boto3==1.35.3
botocore==1.35.3
pydantic==2.8.2
PyJWT==2.9.0
inflection==0.5.1
fhir.resources[xml]==7.1.0
inflection==0.5.1
2 changes: 2 additions & 0 deletions lambdas/services/edge_presign_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(self):
self.table_name_ssm_param = "EDGE_REFERENCE_TABLE"

def use_presign(self, request_values: dict):
logger.info("use presign")
uri: str = request_values["uri"]
querystring: str = request_values["querystring"]
domain_name: str = request_values["domain_name"]
Expand All @@ -35,6 +36,7 @@ def use_presign(self, request_values: dict):

def attempt_presign_ingestion(self, uri_hash: str, domain_name: str) -> None:
try:
logger.info(f"attempting presign ingestion for {domain_name}")
environment = self.filter_domain_for_env(domain_name)
logger.info(f"Environment found: {environment}")
base_table_name: str = self.ssm_service.get_ssm_parameter(
Expand Down
18 changes: 9 additions & 9 deletions lambdas/utils/error_response.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json

from fhir.resources.R4B.operationoutcome import OperationOutcome, OperationOutcomeIssue
# from fhir.resources.R4B.operationoutcome import OperationOutcome, OperationOutcomeIssue


class ErrorResponse:
Expand All @@ -18,14 +18,14 @@ def create(self) -> str:
}
)

def create_error_fhir_response(self) -> str:
operation_outcome = OperationOutcome.construct()
operation_outcome.issue = list()
issue = OperationOutcomeIssue.construct(
code=self.err_code, details=self.message, severity="error"
)
operation_outcome.issue.append(issue)
return operation_outcome.json()
# def create_error_fhir_response(self) -> str:
# operation_outcome = OperationOutcome.construct()
# operation_outcome.issue = list()
# issue = OperationOutcomeIssue.construct(
# code=self.err_code, details=self.message, severity="error"
# )
# operation_outcome.issue.append(issue)
# return operation_outcome.json()

def __eq__(self, other):
return self.err_code == other.err_code and self.message == other.message

0 comments on commit 8c232c9

Please sign in to comment.