Skip to content

Commit

Permalink
lambda handlers explicit in definition.yml #139
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeifer committed Aug 27, 2022
1 parent 9796e77 commit 2dec134
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/cirrus/builtins/feeders/feed-rerun/definition.yml
Expand Up @@ -2,6 +2,7 @@ description: Rerun items in the database
lambda:
memorySize: 128
timeout: 900
handler: lambda_function.lambda_handler
iamRoleStatements:
- Effect: "Allow"
Action:
Expand Down
1 change: 1 addition & 0 deletions src/cirrus/builtins/functions/api/definition.yml
Expand Up @@ -2,6 +2,7 @@ description: Cirrus API
lambda:
memorySize: 128
timeout: 10
handler: lambda_function.lambda_handler
events:
- http: GET /
- http: GET /{proxy+}
Expand Down
1 change: 1 addition & 0 deletions src/cirrus/builtins/functions/process/definition.yml
Expand Up @@ -5,6 +5,7 @@ environment:
lambda:
memorySize: 128
timeout: 900
handler: lambda_function.lambda_handler
events:
- sqs:
arn: !GetAtt ProcessQueue.Arn
Expand Down
1 change: 1 addition & 0 deletions src/cirrus/builtins/functions/update-state/definition.yml
Expand Up @@ -2,6 +2,7 @@ description: update the cirrus database with the execution state
lambda:
memorySize: 128
timeout: 15
handler: lambda_function.lambda_handler
events:
- eventBridge:
pattern:
Expand Down
1 change: 1 addition & 0 deletions src/cirrus/builtins/tasks/post-batch/definition.yml
Expand Up @@ -2,6 +2,7 @@ description: Post process batch job by copying input from S3
lambda:
memorySize: 128
timeout: 15
handler: lambda_function.lambda_handler
iamRoleStatements:
- Effect: "Allow"
Action:
Expand Down
1 change: 1 addition & 0 deletions src/cirrus/builtins/tasks/pre-batch/definition.yml
Expand Up @@ -2,6 +2,7 @@ description: Pre process batch job by copying input to S3
lambda:
memorySize: 128
timeout: 15
handler: lambda_function.lambda_handler
iamRoleStatements:
- Effect: "Allow"
Action:
Expand Down
1 change: 1 addition & 0 deletions src/cirrus/builtins/tasks/publish/definition.yml
Expand Up @@ -2,6 +2,7 @@ description: Publish resulting STAC Collections and Items to catalog, and option
lambda:
memorySize: 128
timeout: 30
handler: lambda_function.lambda_handler
iamRoleStatements:
- Effect: "Allow"
Action:
Expand Down
12 changes: 8 additions & 4 deletions src/cirrus/core/components/base/_lambda.py
Expand Up @@ -63,10 +63,11 @@ def load_config(self):
+ project_reqs
}))

if not hasattr(self.lambda_config, 'module'):
# if this is a non-container lambda that needs to be packaged
# by serverless, then we need to ensure the module points to the
# place in the build dir where we'll copy all the code
if hasattr(self.lambda_config, 'handler'):
self.lambda_config.module = f'lambdas/{self.name}'
if not hasattr(self.lambda_config, 'handler'):
self.lambda_config.handler = 'lambda_function.lambda_handler'

@property
def enabled(self):
Expand All @@ -92,11 +93,14 @@ def copy_for_config(self):
return lc

def get_outdir(self, project_build_dir: Path) -> Path:
return project_build_dir.joinpath(self.lambda_config.module)
return project_build_dir.joinpath(self.lambda_config.module) if self.lambda_enabled else None

def copy_to_outdir(self, outdir: Path) -> None:
import shutil

if not self.lambda_enabled:
return

try:
outdir.mkdir(parents=True)
except FileExistsError:
Expand Down
1 change: 1 addition & 0 deletions src/cirrus/core/components/files/definitions.py
Expand Up @@ -33,6 +33,7 @@
lambda_lambda = '''lambda:
memorySize: 128
timeout: 60
handler: lambda_function.lambda_handler
pythonRequirements:
include: []
'''.format
Expand Down
3 changes: 3 additions & 0 deletions src/cirrus/core/project.py
Expand Up @@ -158,6 +158,9 @@ def build(self) -> None:
# setup all required lambda dirs
fn_dirs = set()
for fn in self.groups.lambdas:
if not fn.lambda_enabled:
continue

outdir = fn.get_outdir(bd).resolve()
if outdir in fn_dirs:
logger.debug(
Expand Down

0 comments on commit 2dec134

Please sign in to comment.