Skip to content

Commit

Permalink
feat: Add lambda dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysiekb committed Dec 28, 2023
1 parent 6e7aafb commit d132281
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
14 changes: 13 additions & 1 deletion backend/backend_stack.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
from aws_cdk import Stack, aws_lambda, aws_apigateway, aws_iam
from aws_cdk import Stack, aws_lambda, aws_apigateway, aws_iam, RemovalPolicy
from aws_cdk.aws_lambda_python_alpha import PythonLayerVersion
from constructs import Construct


class BackendStack(Stack):
def __init__(self, scope: Construct, id: str, **kwargs):
super().__init__(scope, id, **kwargs)

backend_lambda_dependencies = PythonLayerVersion(
scope=self,
id="ChatbotBackendLambdaDependencies",
entry="backend/lambda_dependencies",
compatible_runtimes=[aws_lambda.Runtime.PYTHON_3_11],
removal_policy=RemovalPolicy.DESTROY,
)

backend_lambda = aws_lambda.Function(
scope=self,
id="ChatbotBackendLambda",
runtime=aws_lambda.Runtime.PYTHON_3_11,
handler="backend_lambda.handler",
code=aws_lambda.Code.from_asset("backend/lambda"),
layers=[
backend_lambda_dependencies
]
)

backend_lambda.add_to_role_policy(
Expand Down
1 change: 1 addition & 0 deletions backend/lambda_dependencies/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
boto3
26 changes: 22 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ python = "^3.11"
aws-cdk-lib = "^2.116.1"
constructs = "^10.3.0"
boto3 = "^1.34.9"
aws-cdk-aws-lambda-python-alpha = "^2.117.0a0"


[tool.poetry.group.dev.dependencies]
Expand Down

0 comments on commit d132281

Please sign in to comment.