Skip to content

Commit

Permalink
feat: Deploy backend lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysiekb committed Dec 28, 2023
1 parent 0f949be commit bc78455
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 7 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/cdk-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ jobs:
run: |
cdk deploy ChatbotVpcStack --require-approval never
# - name: Deploy Chatbot Vpc
# uses: youyo/aws-cdk-github-actions@v2
# with:
# cdk_subcommand: deploy
# cdk_stack: ChatbotVpcStack
# cdk_args: "--require-approval never"
# actions_comment: false
- name: Deploy Chatbot Backend
run: |
cdk deploy ChatbotBackendStack --require-approval never
3 changes: 3 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import aws_cdk as cdk

from backend.backend_stack import BackendStack
from base.github_trust_stack import GitHubTrustStack
from base.vpc_stack import VpcStack

app = cdk.App()

# Create the GitHub trust stack in AWS account.
GitHubTrustStack(app, "ChatbotGithubTrustStack")

VpcStack(app, "ChatbotVpcStack")
BackendStack(app, "ChatbotBackendStack")

app.synth()
15 changes: 15 additions & 0 deletions backend/backend_stack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from aws_cdk import Stack, aws_lambda
from constructs import Construct


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

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"),
)
File renamed without changes.
12 changes: 12 additions & 0 deletions backend/lambda/backend_lambda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import json


def handler(event, context):
print('request: {}'.format(json.dumps(event)))
return {
'statusCode': 200,
'headers': {
'Content-Type': 'text/plain'
},
'body': 'Hello, CDK! You have hit {}\n'.format(event['path'])
}
9 changes: 9 additions & 0 deletions backend/model_stack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from aws_cdk import Stack
from constructs import Construct


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


0 comments on commit bc78455

Please sign in to comment.