From c52206eff1d0cb56660c91c386a4a38b08ad372a Mon Sep 17 00:00:00 2001 From: Hamad Alkhal <46822125+hamadsuniverse@users.noreply.github.com> Date: Tue, 27 Feb 2024 17:27:00 +0300 Subject: [PATCH 1/4] Add ci-test file --- .github/ci-test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/ci-test.txt diff --git a/.github/ci-test.txt b/.github/ci-test.txt new file mode 100644 index 0000000..28c218c --- /dev/null +++ b/.github/ci-test.txt @@ -0,0 +1 @@ +v1 \ No newline at end of file From 9c64c27a8be61b0495dab1077f08e70be93c43ed Mon Sep 17 00:00:00 2001 From: Hamad Alkhal <46822125+hamadsuniverse@users.noreply.github.com> Date: Tue, 27 Feb 2024 17:47:55 +0300 Subject: [PATCH 2/4] Added fake bug --- stacks/FrontendStack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stacks/FrontendStack.ts b/stacks/FrontendStack.ts index d55def9..d33dd6e 100644 --- a/stacks/FrontendStack.ts +++ b/stacks/FrontendStack.ts @@ -41,7 +41,7 @@ export function FrontendStack({ stack }: StackContext) { }, } }); - + bug // Show the URLs in the output stack.addOutputs({ SiteUrl: site.url, From 9c5473d4febf95d394afb5737591005a098ebac1 Mon Sep 17 00:00:00 2001 From: Hamad Alkhal <46822125+hamadsuniverse@users.noreply.github.com> Date: Tue, 27 Feb 2024 17:52:12 +0300 Subject: [PATCH 3/4] Fixed fake bug --- stacks/FrontendStack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stacks/FrontendStack.ts b/stacks/FrontendStack.ts index d33dd6e..5faaeb1 100644 --- a/stacks/FrontendStack.ts +++ b/stacks/FrontendStack.ts @@ -41,7 +41,7 @@ export function FrontendStack({ stack }: StackContext) { }, } }); - bug + // Show the URLs in the output stack.addOutputs({ SiteUrl: site.url, From 6df8618140113aff8cb97af35a60fcac1de16edb Mon Sep 17 00:00:00 2001 From: Hamad Alkhal <46822125+hamadsuniverse@users.noreply.github.com> Date: Wed, 28 Feb 2024 10:33:48 +0300 Subject: [PATCH 4/4] Add sample python lambda function --- .../src/sample-python-lambda/lambda.py | 3 +++ .../src/sample-python-lambda/requirements.txt | 0 stacks/ApiStack.ts | 23 +++++++++++++------ 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 packages/functions/src/sample-python-lambda/lambda.py create mode 100644 packages/functions/src/sample-python-lambda/requirements.txt diff --git a/packages/functions/src/sample-python-lambda/lambda.py b/packages/functions/src/sample-python-lambda/lambda.py new file mode 100644 index 0000000..d787cba --- /dev/null +++ b/packages/functions/src/sample-python-lambda/lambda.py @@ -0,0 +1,3 @@ + +def main(event, context): + return "Hello from Lambda" \ No newline at end of file diff --git a/packages/functions/src/sample-python-lambda/requirements.txt b/packages/functions/src/sample-python-lambda/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/stacks/ApiStack.ts b/stacks/ApiStack.ts index b9f90b2..07a6d15 100644 --- a/stacks/ApiStack.ts +++ b/stacks/ApiStack.ts @@ -6,18 +6,27 @@ import { Duration } from "aws-cdk-lib/core"; export function ApiStack({ stack }: StackContext) { const {table} = use(DBStack); - + // Create the HTTP API const api = new Api(stack, "Api", { defaults: { - function: { - // Bind the table name to our API - bind: [table], - }, + function: { + // Bind the table name to our API + bind: [table], + }, }, routes: { - "POST /": "packages/functions/src/lambda.main", - }, + // Sample TypeScript lambda function + "POST /": "packages/functions/src/lambda.main", + // Sample Pyhton lambda function + "GET /": { + function: { + handler: "packages/functions/src/sample-python-lambda/lambda.main", + runtime: "python3.11", + timeout: "60 seconds", + } + }, + } }); // cache policy to use with cloudfront as reverse proxy to avoid cors