async-lambda-unstable 0.6.2__tar.gz → 0.6.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/PKG-INFO +1 -1
  2. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/__init__.py +1 -1
  3. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/build_config.py +42 -4
  4. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/cli.py +3 -1
  5. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/config.py +15 -3
  6. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/controller.py +70 -10
  7. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/models/task.py +32 -69
  8. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/.gitignore +0 -0
  9. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/README.md +0 -0
  10. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/client.py +0 -0
  11. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/defer.py +0 -0
  12. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/env.py +0 -0
  13. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/middleware.py +0 -0
  14. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/models/__init__.py +0 -0
  15. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/models/api_response.py +0 -0
  16. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/models/case_insensitive_dict.py +0 -0
  17. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/models/events/__init__.py +0 -0
  18. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/models/events/api_event.py +0 -0
  19. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/models/events/base_event.py +0 -0
  20. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/models/events/dynamodb_event.py +0 -0
  21. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/models/events/managed_sqs_batch_event.py +0 -0
  22. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/models/events/managed_sqs_event.py +0 -0
  23. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/models/events/scheduled_event.py +0 -0
  24. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/models/events/unmanaged_sqs_event.py +0 -0
  25. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/models/mock/mock_context.py +0 -0
  26. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/models/mock/mock_event.py +0 -0
  27. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/payload_encoder.py +0 -0
  28. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/py.typed +0 -0
  29. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/async_lambda/util.py +0 -0
  30. {async_lambda_unstable-0.6.2 → async_lambda_unstable-0.6.3}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: async-lambda-unstable
3
- Version: 0.6.2
3
+ Version: 0.6.3
4
4
  Summary: A framework for creating AWS Lambda Async Workflows. - Unstable Branch
5
5
  Author-email: "Nuclei, Inc" <engineering@nuclei.ai>
6
6
  Requires-Dist: click>=8.0.0
@@ -21,4 +21,4 @@ from .models.events.managed_sqs_event import ManagedSQSEvent as ManagedSQSEvent
21
21
  from .models.events.scheduled_event import ScheduledEvent as ScheduledEvent
22
22
  from .models.events.unmanaged_sqs_event import UnmanagedSQSEvent as UnmanagedSQSEvent
23
23
 
24
- __version__ = "0.6.2"
24
+ __version__ = "0.6.3"
@@ -119,6 +119,23 @@ class AsyncLambdaBuildConfig:
119
119
  if other.auto_create_acm_certificate is not None:
120
120
  self.auto_create_acm_certificate = other.auto_create_acm_certificate
121
121
 
122
+ @property
123
+ def function_properties(self):
124
+ function_properties = {}
125
+ if len(self.layers) > 0:
126
+ function_properties["Layers"] = sorted(self.layers)
127
+ if len(self.security_group_ids) > 0 or len(self.subnet_ids) > 0:
128
+ function_properties["VpcConfig"] = {}
129
+ if len(self.security_group_ids) > 0:
130
+ function_properties["VpcConfig"]["SecurityGroupIds"] = sorted(
131
+ self.security_group_ids
132
+ )
133
+ if len(self.subnet_ids) > 0:
134
+ function_properties["VpcConfig"]["SubnetIds"] = sorted(self.subnet_ids)
135
+ if len(self.logging_config) > 0:
136
+ function_properties["LoggingConfig"] = self.logging_config
137
+ return function_properties
138
+
122
139
 
123
140
  def get_build_config_for_stage(
124
141
  config: dict, stage: Optional[str] = None
@@ -154,8 +171,7 @@ def get_build_config_for_task(
154
171
  Retrieves and constructs the build configuration for a specific task and optional stage.
155
172
 
156
173
  This function applies default build configuration values, then overrides them with
157
- task-specific and stage-specific configuration if available. It also updates the build
158
- configuration with default tags.
174
+ task-specific and stage-specific configuration if available.
159
175
 
160
176
  Args:
161
177
  config (dict): The overall configuration dictionary containing tasks and stages.
@@ -166,8 +182,31 @@ def get_build_config_for_task(
166
182
  AsyncLambdaBuildConfig: The merged build configuration for the specified task and stage.
167
183
  """
168
184
  # Apply Defaults
169
- build_config = get_build_config_for_stage(config, stage)
185
+ build_config = get_build_config_for_stage(config=config, stage=stage)
186
+ # Retrieve Task-Specific Overrides
187
+ override_config = get_override_build_config_for_task(
188
+ config=config, task_id=task_id, stage=stage
189
+ )
190
+ # Take the super-set of both configurations, prioritizing task-specific values on conflicts
191
+ build_config.merge(override_config)
192
+ return build_config
193
+
194
+
195
+ def get_override_build_config_for_task(
196
+ config: dict, task_id: str, stage: Optional[str] = None
197
+ ) -> AsyncLambdaBuildConfig:
198
+ """
199
+ Retrieves and constructs the build configuration, containing solely task-specific overrides, for a specific task and optional stage.
170
200
 
201
+ Args:
202
+ config (dict): The overall configuration dictionary containing tasks and stages.
203
+ task_id (str): The identifier for the task to retrieve configuration for.
204
+ stage (Optional[str], optional): The stage name to retrieve configuration for. Defaults to None.
205
+
206
+ Returns:
207
+ AsyncLambdaBuildConfig: The build configuration with only override values for the specified task and stage.
208
+ """
209
+ build_config = AsyncLambdaBuildConfig.new({})
171
210
  if task_id in config.setdefault("tasks", {}):
172
211
  # Apply task defaults
173
212
  task_config = config["tasks"].setdefault(task_id, {})
@@ -179,5 +218,4 @@ def get_build_config_for_task(
179
218
  stage, {}
180
219
  )
181
220
  build_config.merge(AsyncLambdaBuildConfig.new(task_stage_config))
182
- build_config.tags.update(make_default_tags())
183
221
  return build_config
@@ -140,7 +140,9 @@ def build(
140
140
  raise click.ClickException("Extras file contains invalid formatted data.")
141
141
 
142
142
  click.echo("Generating SAM template...")
143
- template = controller.generate_sam_template(module, config, stage=stage)
143
+ template = controller.generate_sam_template(
144
+ module=module, config_dict=config, stage=stage
145
+ )
144
146
  if extras_json is not None:
145
147
  click.echo("Merging template with extras...")
146
148
  nested_update(template, extras_json)
@@ -8,14 +8,16 @@ class AsyncLambdaConfig:
8
8
  Attributes:
9
9
  name (str): Name of the async lambda application. Defaults to "async-lambda".
10
10
  runtime (str): Runtime environment for the lambda function. Defaults to "python3.10".
11
- s3_payload_retention (Optional[int]): Days to retain payloads in S3. Defaults to 30.
11
+ s3_payload_retention (int): Days to retain payloads in S3. Defaults to 30.
12
12
  default_task_memory (int): Default memory allocation (MB) for tasks. Defaults to 128.
13
+ default_task_ephemeral_storage (int): Default disk allocation (MB) for tasks. Defaults to 512.
13
14
  """
14
15
 
15
16
  name: str = "async-lambda"
16
17
  runtime: str = "python3.10"
17
18
  s3_payload_retention: Optional[int] = 30
18
19
  default_task_memory: int = 128
20
+ default_task_ephemeral_storage: int = 512
19
21
 
20
22
 
21
23
  config = AsyncLambdaConfig()
@@ -41,12 +43,12 @@ def config_set_runtime(runtime: str):
41
43
  config.runtime = runtime
42
44
 
43
45
 
44
- def config_set_s3_payload_retention(days: Optional[int]):
46
+ def config_set_s3_payload_retention(days: int = 30):
45
47
  """
46
48
  Set the S3 payload retention policy in days.
47
49
 
48
50
  Args:
49
- days (Optional[int]): Number of days to retain payloads in S3.
51
+ days (int, optional): Number of days to retain payloads in S3. Defaults to 30.
50
52
  """
51
53
  config.s3_payload_retention = days
52
54
 
@@ -59,3 +61,13 @@ def config_set_default_task_memory(memory: int = 128):
59
61
  memory (int, optional): Memory in megabytes to set as default for tasks. Defaults to 128.
60
62
  """
61
63
  config.default_task_memory = memory
64
+
65
+
66
+ def config_set_default_task_ephemeral_storage(ephemeral_storage: int = 512):
67
+ """
68
+ Set the default ephemeral_storage (MB) for tasks.
69
+
70
+ Args:
71
+ ephemeral_storage (int, optional): Disk storage in megabytes to set as default for tasks. Defaults to 512.
72
+ """
73
+ config.default_task_ephemeral_storage = ephemeral_storage
@@ -366,9 +366,30 @@ class AsyncLambdaController:
366
366
  }
367
367
  ]
368
368
  }
369
+
369
370
  template = {
370
371
  "AWSTemplateFormatVersion": "2010-09-09",
371
372
  "Transform": "AWS::Serverless-2016-10-31",
373
+ "Globals": {
374
+ "Function": {
375
+ "Tags": build_config.tags,
376
+ "Handler": f"{module}.lambda_handler",
377
+ "Runtime": config.runtime,
378
+ "Environment": {
379
+ "Variables": {
380
+ "ASYNC_LAMBDA_PAYLOAD_S3_BUCKET": {
381
+ "Ref": "AsyncLambdaPayloadBucket"
382
+ },
383
+ "ASYNC_LAMBDA_ACCOUNT_ID": {"Ref": "AWS::AccountId"},
384
+ **build_config.environment_variables,
385
+ },
386
+ },
387
+ "CodeUri": ".async_lambda/build/deployment.zip",
388
+ "MemorySize": config.default_task_memory,
389
+ "EphemeralStorage": {"Size": config.default_task_ephemeral_storage},
390
+ **build_config.function_properties,
391
+ }
392
+ },
372
393
  "Resources": {
373
394
  "AsyncLambdaPayloadBucket": {
374
395
  "Type": "AWS::S3::Bucket",
@@ -392,14 +413,53 @@ class AsyncLambdaController:
392
413
  },
393
414
  }
394
415
  _task_list = list(self.tasks.values())
416
+ managed_tasks_resources = [
417
+ resource
418
+ for task in _task_list
419
+ if task.trigger_type in MANAGED_SQS_TASK_TYPES
420
+ for resource in task.get_policy_sqs_resources()
421
+ ] + [
422
+ resource
423
+ for external_async_task_id in self.external_async_tasks
424
+ for resource in AsyncLambdaTask.get_policy_external_task_resources(
425
+ external_async_task_id
426
+ )
427
+ ]
428
+ task_ref_policies = {}
429
+ if len(managed_tasks_resources) > 0:
430
+ task_ref_policies = {
431
+ "SendToAllAsyncLambdaQueuesPolicy": {
432
+ "Type": "AWS::IAM::ManagedPolicy",
433
+ "Properties": {
434
+ "ManagedPolicyName": {
435
+ "Fn::Sub": "${AWS::StackName}-send-to-all-queues"
436
+ },
437
+ "PolicyDocument": {
438
+ "Version": "2012-10-17",
439
+ "Statement": [
440
+ {
441
+ "Sid": "SendToAllQueues",
442
+ "Effect": "Allow",
443
+ "Action": ["sqs:SendMessage"],
444
+ "Resource": [
445
+ managed_tasks_resource
446
+ for managed_tasks_resource in managed_tasks_resources
447
+ ],
448
+ },
449
+ ],
450
+ },
451
+ },
452
+ }
453
+ }
454
+ for key in task_ref_policies.keys():
455
+ template["Resources"][key] = task_ref_policies[key]
456
+
395
457
  has_api_tasks = False
396
458
  for task in _task_list:
397
459
  if task.trigger_type == TaskTriggerType.API_EVENT:
398
460
  has_api_tasks = True
399
461
  for logical_id, resource in task.get_sam_template(
400
- module=module,
401
- tasks=_task_list,
402
- external_async_tasks=self.external_async_tasks,
462
+ task_ref_policy_ids=list(task_ref_policies.keys()),
403
463
  config_dict=config_dict,
404
464
  stage=stage,
405
465
  ).items():
@@ -1196,7 +1256,7 @@ class AsyncLambdaController:
1196
1256
  propagate_lane_assignment: Optional[bool] = None,
1197
1257
  timeout: int = 60,
1198
1258
  memory: Optional[int] = None,
1199
- ephemeral_storage: int = 512,
1259
+ ephemeral_storage: Optional[int] = None,
1200
1260
  **kwargs,
1201
1261
  ):
1202
1262
  """
@@ -1273,7 +1333,7 @@ class AsyncLambdaController:
1273
1333
  max_batching_window: Optional[int] = None,
1274
1334
  timeout: int = 60,
1275
1335
  memory: Optional[int] = None,
1276
- ephemeral_storage: int = 512,
1336
+ ephemeral_storage: Optional[int] = None,
1277
1337
  **kwargs,
1278
1338
  ):
1279
1339
  """
@@ -1345,7 +1405,7 @@ class AsyncLambdaController:
1345
1405
  queue_arn: str,
1346
1406
  timeout: int = 60,
1347
1407
  memory: Optional[int] = None,
1348
- ephemeral_storage: int = 512,
1408
+ ephemeral_storage: Optional[int] = None,
1349
1409
  **kwargs,
1350
1410
  ):
1351
1411
  """
@@ -1405,7 +1465,7 @@ class AsyncLambdaController:
1405
1465
  schedule_expression: str,
1406
1466
  timeout: int = 60,
1407
1467
  memory: Optional[int] = None,
1408
- ephemeral_storage: int = 512,
1468
+ ephemeral_storage: Optional[int] = None,
1409
1469
  **kwargs,
1410
1470
  ):
1411
1471
  """
@@ -1466,7 +1526,7 @@ class AsyncLambdaController:
1466
1526
  method: str,
1467
1527
  timeout: int = 60,
1468
1528
  memory: Optional[int] = None,
1469
- ephemeral_storage: int = 512,
1529
+ ephemeral_storage: Optional[int] = None,
1470
1530
  **kwargs,
1471
1531
  ):
1472
1532
  """
@@ -1531,7 +1591,7 @@ class AsyncLambdaController:
1531
1591
  max_batching_window: int = 0,
1532
1592
  timeout: int = 60,
1533
1593
  memory: Optional[int] = None,
1534
- ephemeral_storage: int = 512,
1594
+ ephemeral_storage: Optional[int] = None,
1535
1595
  **kwargs,
1536
1596
  ):
1537
1597
  """
@@ -1599,7 +1659,7 @@ class AsyncLambdaController:
1599
1659
  task_id: str,
1600
1660
  timeout: int = 60,
1601
1661
  memory: Optional[int] = None,
1602
- ephemeral_storage: int = 512,
1662
+ ephemeral_storage: Optional[int] = None,
1603
1663
  **kwargs,
1604
1664
  ):
1605
1665
  """
@@ -9,13 +9,12 @@ from typing import (
9
9
  Generic,
10
10
  List,
11
11
  Optional,
12
- Set,
13
12
  TypeVar,
14
13
  Union,
15
14
  )
16
15
 
17
16
  from .. import env
18
- from ..build_config import get_build_config_for_task
17
+ from ..build_config import get_build_config_for_task, get_override_build_config_for_task
19
18
  from ..config import config
20
19
  from ..util import make_cf_tags
21
20
 
@@ -86,7 +85,7 @@ class AsyncLambdaTask(Generic[EventType, RT]):
86
85
  trigger_config (dict): Configuration specific to the trigger type.
87
86
  timeout (int): Lambda function timeout (seconds).
88
87
  memory (Optional[int]): Memory size for the Lambda function.
89
- ephemeral_storage (int): Ephemeral storage size for the Lambda function.
88
+ ephemeral_storage (Optional[int]): Ephemeral storage size for the Lambda function.
90
89
  maximum_concurrency (Optional[Union[int, List[int]]]): Maximum concurrency for the task or per lane.
91
90
  init_tasks (List[Union[Callable[[str], Any], Callable[[], Any]]]): Initialization tasks to run before execution.
92
91
  _has_run_init_tasks (bool): Flag indicating if initialization tasks have been run.
@@ -100,7 +99,7 @@ class AsyncLambdaTask(Generic[EventType, RT]):
100
99
 
101
100
  timeout: int
102
101
  memory: Optional[int]
103
- ephemeral_storage: int
102
+ ephemeral_storage: Optional[int]
104
103
  maximum_concurrency: Optional[Union[int, List[int]]]
105
104
  init_tasks: List[Union[Callable[[str], Any], Callable[[], Any]]]
106
105
  _has_run_init_tasks: bool
@@ -116,7 +115,7 @@ class AsyncLambdaTask(Generic[EventType, RT]):
116
115
  trigger_config: Optional[dict] = None,
117
116
  timeout: int = 60,
118
117
  memory: Optional[int] = None,
119
- ephemeral_storage: int = 512,
118
+ ephemeral_storage: Optional[int] = None,
120
119
  maximum_concurrency: Optional[Union[int, List[int]]] = None,
121
120
  init_tasks: Optional[
122
121
  List[Union[Callable[[str], Any], Callable[[], Any]]]
@@ -133,7 +132,7 @@ class AsyncLambdaTask(Generic[EventType, RT]):
133
132
  trigger_config (Optional[dict], optional): Configuration for the trigger. Defaults to None.
134
133
  timeout (int, optional): Maximum execution time (seconds). Defaults to 60.
135
134
  memory (Optional[int], optional): Memory allocation (MB). Defaults to None.
136
- ephemeral_storage (int, optional): Ephemeral storage (MB). Defaults to 512.
135
+ ephemeral_storage (Optional[int], optional): Ephemeral storage (MB). Defaults to None.
137
136
  maximum_concurrency (Optional[Union[int, List[int]]], optional): Maximum concurrency for the task. Defaults to None.
138
137
  init_tasks (Optional[List[Union[Callable[[str], Any], Callable[[], Any]]]], optional): Initialization tasks to run before execution. Defaults to None.
139
138
 
@@ -540,26 +539,29 @@ class AsyncLambdaTask(Generic[EventType, RT]):
540
539
 
541
540
  def get_sam_template(
542
541
  self,
543
- module: str,
544
- tasks: List["AsyncLambdaTask"],
545
- external_async_tasks: Set[str],
542
+ task_ref_policy_ids: List[str],
546
543
  config_dict: dict,
547
544
  stage: Optional[str] = None,
548
545
  ) -> dict:
549
546
  """
550
547
  Generate an AWS SAM (Serverless Application Model) template for the current async lambda task.
551
548
 
549
+ This template inherits the global SAM values provided via the controller's generate_sam_template(...) method.
550
+
552
551
  Args:
553
- module (str): Python module containing the Lambda handler.
554
- tasks (List[AsyncLambdaTask]): All async lambda tasks in the deployment.
555
- external_async_tasks (Set[str]): External async task IDs referenced by this task.
552
+ task_ref_policy_ids (List[str]): List of ManagedPolicy logical IDs to attach via CloudFormation Ref.
556
553
  config_dict (dict): Configuration dictionary for deployment settings.
557
554
  stage (Optional[str], optional): Deployment stage (e.g., 'dev', 'prod'). Defaults to None.
558
555
 
559
556
  Returns:
560
557
  dict: SAM template resources for this task.
561
558
  """
562
- build_config = get_build_config_for_task(config_dict, self.task_id, stage=stage)
559
+ build_config = get_build_config_for_task(
560
+ config=config_dict, task_id=self.task_id, stage=stage
561
+ )
562
+ override_config = get_override_build_config_for_task(
563
+ config=config_dict, task_id=self.task_id, stage=stage
564
+ )
563
565
  events = self.get_template_events()
564
566
  policy_sqs_resources = self.get_policy_sqs_resources()
565
567
 
@@ -583,29 +585,6 @@ class AsyncLambdaTask(Generic[EventType, RT]):
583
585
  },
584
586
  },
585
587
  ]
586
- managed_tasks_resources = [
587
- resource
588
- for task in tasks
589
- if task.trigger_type in MANAGED_SQS_TASK_TYPES
590
- for resource in task.get_policy_sqs_resources()
591
- ] + [
592
- resource
593
- for external_async_task_id in external_async_tasks
594
- for resource in self.get_policy_external_task_resources(
595
- external_async_task_id
596
- )
597
- ]
598
- if len(managed_tasks_resources) > 0:
599
- policy_statements.append(
600
- {
601
- "Effect": "Allow",
602
- "Action": ["sqs:SendMessage"],
603
- "Resource": [
604
- managed_tasks_resource
605
- for managed_tasks_resource in managed_tasks_resources
606
- ],
607
- },
608
- )
609
588
  if len(policy_sqs_resources) > 0:
610
589
  policy_statements.append(
611
590
  {
@@ -620,55 +599,39 @@ class AsyncLambdaTask(Generic[EventType, RT]):
620
599
  "Resource": policy_sqs_resources,
621
600
  },
622
601
  )
623
- function_properties = {}
624
- if len(build_config.layers) > 0:
625
- function_properties["Layers"] = sorted(build_config.layers)
626
- if len(build_config.security_group_ids) > 0 or len(build_config.subnet_ids) > 0:
627
- function_properties["VpcConfig"] = {}
628
- if len(build_config.security_group_ids) > 0:
629
- function_properties["VpcConfig"]["SecurityGroupIds"] = sorted(
630
- build_config.security_group_ids
631
- )
632
- if len(build_config.subnet_ids) > 0:
633
- function_properties["VpcConfig"]["SubnetIds"] = sorted(
634
- build_config.subnet_ids
635
- )
636
- if len(build_config.logging_config) > 0:
637
- function_properties["LoggingConfig"] = build_config.logging_config
602
+
603
+ policies = [
604
+ {"Statement": policy_statements},
605
+ *build_config.policies,
606
+ *[{"Ref": policy_id} for policy_id in task_ref_policy_ids],
607
+ ]
638
608
 
639
609
  template = {
640
610
  self.get_function_logical_id(): {
641
611
  "Type": "AWS::Serverless::Function",
642
612
  "Properties": {
643
- "Tags": build_config.tags,
644
- "Handler": f"{module}.lambda_handler",
645
- "Runtime": config.runtime,
646
613
  "Environment": {
647
614
  "Variables": {
648
- "ASYNC_LAMBDA_PAYLOAD_S3_BUCKET": {
649
- "Ref": "AsyncLambdaPayloadBucket"
650
- },
651
615
  "ASYNC_LAMBDA_TASK_ID": self.task_id,
652
- "ASYNC_LAMBDA_ACCOUNT_ID": {"Ref": "AWS::AccountId"},
653
- **build_config.environment_variables,
616
+ **override_config.environment_variables,
654
617
  }
655
618
  },
656
619
  "FunctionName": self.get_function_name(),
657
- "CodeUri": ".async_lambda/build/deployment.zip",
658
- "EphemeralStorage": {"Size": self.ephemeral_storage},
659
- "MemorySize": (
660
- self.memory if self.memory else config.default_task_memory
661
- ),
662
620
  "Timeout": self.timeout,
663
621
  "Events": events,
664
- "Policies": [
665
- {"Statement": policy_statements},
666
- *build_config.policies,
667
- ],
668
- **function_properties,
622
+ "Policies": policies,
623
+ **override_config.function_properties,
669
624
  },
670
625
  }
671
626
  }
627
+ if self.memory is not None:
628
+ template[self.get_function_logical_id()]["Properties"]["MemorySize"] = (
629
+ self.memory
630
+ )
631
+ if self.ephemeral_storage is not None:
632
+ template[self.get_function_logical_id()]["Properties"][
633
+ "EphemeralStorage"
634
+ ] = {"Size": self.ephemeral_storage}
672
635
 
673
636
  if self.trigger_type in MANAGED_SQS_TASK_TYPES:
674
637
  dlq_task = self.get_dlq_task()