Skip to content

Commit

Permalink
add logging on invoker
Browse files Browse the repository at this point in the history
  • Loading branch information
joelbalcaen committed Apr 19, 2024
1 parent f227ebd commit e5c922d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
20 changes: 16 additions & 4 deletions lambdas/email_attachment_saver/src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,29 @@ def lambda_handler(event, context):
"""
This lambda saves email attachments to S3.
It expects to receive the s3 bucket and folder where the attachments will be saved
It expects the following event structure:
{
"bucket": "the s3 bucket to store the attachments in",
"s3_folder": "s3 folder to store the attachments in",
"Records": [
{
"ses": {
"mail": {
"content": "base64 encoded email"
}
}
}
]
}
Returns: A dictionary containing the status code, a message, and the list of attachment ARNs
"""

logger.info(event)
bucket = event['bucket']
s3_folder = event['s3_folder']
raw_email_data = event['Records'][0]['ses']['mail']['content']

msg = email.message_from_bytes(base64.b64decode(raw_email_data))


attachment_arns = []

if msg.is_multipart():
Expand Down
7 changes: 5 additions & 2 deletions lambdas/step_function_invoker/src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@ def lambda_handler(event, context):
input=event,
)

logger.info(state_machine_execution_result)
return {
"statusCode": 200,
"body": json.dumps(state_machine_execution_result),
}

except ParamValidationError as e:
logger.error(e)
return {
"statusCode": 400,
"body": json.dumps({"error": "Parameter validation error", "details": str(e)}),
}

except Exception as e:
logger.error(e)
return {
"statusCode": 400,
"body": json.dumps(e),
Expand Down

0 comments on commit e5c922d

Please sign in to comment.