From a58e699ecb9d4204e5e8baf08047cb050f0c0d39 Mon Sep 17 00:00:00 2001 From: Tom Victor Date: Mon, 8 Apr 2024 10:09:53 +0200 Subject: [PATCH] add helper for nodejs lambda function --- Cargo.toml | 2 +- aws_packages/infra/common_stack.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 1d151d3..fefd761 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aws_packages" -version = "0.0.10" +version = "0.0.12" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/aws_packages/infra/common_stack.py b/aws_packages/infra/common_stack.py index d4f2087..1126a14 100644 --- a/aws_packages/infra/common_stack.py +++ b/aws_packages/infra/common_stack.py @@ -55,6 +55,27 @@ def _create_python_lambda_function( ) return _lambda_function + def _create_node_lambda_function( + self, + identifier: str, + source: str, + lambda_layers: list, + envs: dict, + function_handler: str, + ): + _lambda_function = lambda_.Function( + self, + identifier, + function_name=identifier, + code=lambda_.Code.from_asset(path.join(source)), + handler=function_handler, + runtime=lambda_.Runtime.NODEJS_20_X, + timeout=Duration.seconds(300), + layers=lambda_layers, + environment=envs, + ) + return _lambda_function + def _create_api_gw(self, identifier: str, handler_function): api_gateway_resource = apigw.LambdaRestApi( self,