-
Notifications
You must be signed in to change notification settings - Fork 5
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
[treasury-report] Update Send Treasury Report by email
button to only send the email and not trigger the step function
#516
Closed
Closed
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
8bb7938
add pre-commit to clean up code
nowei eefc291
Merge remote-tracking branch 'origin' into nowei/pre-commit
nowei 796c465
mypy checking
nowei f3645d1
add typing to everything
nowei e80c9e2
merging
nowei a592e54
Send treasury report by email
nowei 1bcb125
prettier
nowei 367efbf
update test
nowei 6a73951
mocking
nowei 5ffe10f
merging
nowei e4c637f
add handling for SQS items in the lambda
nowei 20ff599
add a comment
nowei 4a1e772
test adding sqs message to localstack
nowei be4eac4
process sqs event body
nowei 1a1723c
init commit in case I mess things up
nowei 36c7dd3
add instructions for zipping up lambda file
nowei e438fed
add instructions for localstack send treasury email lambda testing (u…
nowei 48f475b
Merge remote-tracking branch 'origin' into nowei/send-treasury-report…
nowei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import os | ||
from typing import Any, Optional, Tuple | ||
from typing import Any, Dict, Optional, Tuple | ||
|
||
import boto3 | ||
import chevron | ||
|
@@ -28,7 +28,7 @@ class SendTreasuryEmailLambdaPayload(BaseModel): | |
|
||
|
||
@reset_contextvars | ||
def handle(event: SendTreasuryEmailLambdaPayload, context: Context) -> dict[str, Any]: | ||
def handle(event: Dict[str, Any], context: Context) -> dict[str, Any]: | ||
"""Lambda handler for emailing Treasury reports | ||
|
||
Given a user and organization object- send an email to the user that | ||
|
@@ -37,18 +37,24 @@ def handle(event: SendTreasuryEmailLambdaPayload, context: Context) -> dict[str, | |
If the object does not exist then raise an exception. | ||
|
||
Args: | ||
event: S3 Lambda event of type `s3:ObjectCreated:*` | ||
event: S3 Lambda event of type `s3:ObjectCreated:*` or a single SQS message | ||
with a `Records` field | ||
context: Lambda context | ||
""" | ||
structlog.contextvars.bind_contextvars(lambda_event={"step_function": event}) | ||
logger = get_logger() | ||
logger.info("received new invocation event from step function") | ||
|
||
try: | ||
# Lambda payload | ||
payload = SendTreasuryEmailLambdaPayload.model_validate(event) | ||
except Exception: | ||
logger.exception("Exception parsing Send Treasury Email event payload") | ||
return {"statusCode": 400, "body": "Bad Request"} | ||
try: | ||
# SQS event | ||
payload = SendTreasuryEmailLambdaPayload.model_validate(event["Records"][0]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
except Exception: | ||
logger.exception("Exception parsing Send Treasury Email event payload") | ||
return {"statusCode": 400, "body": "Bad Request"} | ||
|
||
try: | ||
process_event(payload, logger) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed for proper SQS message routing in the local development environment: localstack/localstack#10590 (comment)