Skip to content
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

add sqs_handler support #7

Open
wants to merge 1 commit into
base: event_bridge_handler_support
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions zappa/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class ZappaCLI(object):
aws_kms_key_arn = ''
web_socket_handler = None
event_bridge_handler = None
sqs_handler = None

cognito_authorizer_path = '/'

Expand Down Expand Up @@ -1828,6 +1829,7 @@ def load_settings(self, settings_file=None, session=None):
# custom zappa settings key for aws event bride
self.event_bridge_handler = \
self.stage_config.get("event_bridge_handler")
self.sqs_handler = self.stage_config.get("sqs_handler")

desired_role_name = self.lambda_name + "-ZappaLambdaExecutionRole"
self.zappa = Zappa( boto_session=session,
Expand Down Expand Up @@ -2113,6 +2115,13 @@ def create_package(self, output=None):
else:
settings_s += "EVENT_BRIDGE_HANDLER=None\n"

# sqs function
if self.sqs_handler:
settings_s += "SQS_HANDLER='{0!s}'\n".format(
self.sqs_handler)
else:
settings_s += "SQS_HANDLER=None\n"

# Copy our Django app into root of our package.
# It doesn't work otherwise.
if self.django_settings:
Expand Down
4 changes: 3 additions & 1 deletion zappa/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def get_function_for_aws_event(self, record):
"""
Get the associated function to execute for a triggered AWS event

Support S3, SNS, DynamoDB, kinesis and Event bridge events
Support S3, SNS, DynamoDB, kinesis, SQS and Event bridge events
"""
if 's3' in record:
return record['s3']['configurationId'].split(':')[-1]
Expand All @@ -337,6 +337,8 @@ def get_function_for_aws_event(self, record):
is_event_bridge_record = "detail-type" in body and "source" in body
if is_event_bridge_record:
return self.settings.EVENT_BRIDGE_HANDLER
else:
return self.settings.SQS_HANDLER

if arn:
return self.settings.AWS_EVENT_MAPPING.get(arn)
Expand Down