diff --git a/tests/tests_placebo.py b/tests/tests_placebo.py index 2b8f43cf8..1b6789c9a 100644 --- a/tests/tests_placebo.py +++ b/tests/tests_placebo.py @@ -532,6 +532,63 @@ def test_add_event_source(self, session): session, dry=True, ) + event_source = { + "arn": "sqs:sqs:sqs:sqs", + "events": [ + { + "function": "function_name", + "event_source": { + "arn": "dummy", + "batch_size": 100, + "batch_window": 10, + "functionResponseType": "ReportBatchItemFailures", + "enabled": True, + }, + } + ], + } + add_event_source( + event_source, + "sqs:sqs:sqs:sqs", + "test_settings.callback", + session, + dry=True, + ) + remove_event_source( + event_source, + "sqs:sqs:sqs:sqs", + "test_settings.callback", + session, + dry=True, + ) + event_source = { + "arn": "sqs:sqs:sqs:sqs", + "events": [ + { + "function": "function_name", + "event_source": { + "arn": "dummy", + "batch_size": 100, + "functionResponseType": "ReportBatchItemFailures", + "enabled": True, + }, + } + ], + } + add_event_source( + event_source, + "sqs:sqs:sqs:sqs", + "test_settings.callback", + session, + dry=True, + ) + remove_event_source( + event_source, + "sqs:sqs:sqs:sqs", + "test_settings.callback", + session, + dry=True, + ) # get_event_source_status(event_source, 'lambda:lambda:lambda:lambda', 'test_settings.callback', session, dry=True) @placebo_session diff --git a/zappa/utilities.py b/zappa/utilities.py index cffbd0ae0..43e144b5d 100644 --- a/zappa/utilities.py +++ b/zappa/utilities.py @@ -265,6 +265,10 @@ def __init__(self, context, config): super().__init__(context, config) self._lambda = kappa.awsclient.create_client("lambda", context.session) + @property + def batch_window(self): + return self._config.get("batch_window", 1 if self.batch_size > 10 else 0) + def _get_uuid(self, function): uuid = None response = self._lambda.call( @@ -284,6 +288,7 @@ def add(self, function): FunctionName=function.name, EventSourceArn=self.arn, BatchSize=self.batch_size, + MaximumBatchingWindowInSeconds=self.batch_window, Enabled=self.enabled, ) LOG.debug(response) @@ -322,6 +327,7 @@ def update(self, function): response = self._lambda.call( "update_event_source_mapping", BatchSize=self.batch_size, + MaximumBatchingWindowInSeconds=self.batch_window, Enabled=self.enabled, FunctionName=function.arn, )