From 6e8a818d2e2c21b8939757520bea840e67d78d6e Mon Sep 17 00:00:00 2001 From: Krzysztof Banasiak Date: Thu, 28 Dec 2023 13:54:24 +0100 Subject: [PATCH] feat: Deploy backend api gateway --- backend/backend_stack.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/backend/backend_stack.py b/backend/backend_stack.py index 0f9d5d5..7b62091 100644 --- a/backend/backend_stack.py +++ b/backend/backend_stack.py @@ -1,4 +1,4 @@ -from aws_cdk import Stack, aws_lambda +from aws_cdk import Stack, aws_lambda, aws_apigateway from constructs import Construct @@ -6,10 +6,21 @@ class BackendStack(Stack): def __init__(self, scope: Construct, id: str, **kwargs): super().__init__(scope, id, **kwargs) - aws_lambda.Function( + 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"), ) + + backend_apigw = aws_apigateway.LambdaRestApi( + scope=self, + id="ChatbotBackendAPI", + handler=backend_lambda, + ) + + chatbot_res = backend_apigw.root.add_resource("chatbot") + + chatbot_res.add_method("GET") + chatbot_res.add_method("POST")