From d81bada2dafb4d3788ee478f84d73c956f101009 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 7 May 2026 11:50:30 +0200 Subject: [PATCH 01/37] feat: update code to be compatible with AWS Lambda --- 01-ci-lab/app/calculator.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/01-ci-lab/app/calculator.py b/01-ci-lab/app/calculator.py index 6c79abc..e4c9cca 100644 --- a/01-ci-lab/app/calculator.py +++ b/01-ci-lab/app/calculator.py @@ -5,6 +5,20 @@ def add(a, b): def divide(a, b): return a / b +def lambda_handler(event, context): + a = event["a"] + b = event["b"] -def divide2(a, b): - return a / b + operation = event["operation"] + + if operation == "add": + result = add(a, b) + elif operation == "divide": + result = divide(a, b) + else: + return {"statusCode": 400, "body": "Unsupported operation"} + + return { + "statusCode": 200, + "body": result + } From 7693b8c12e8cf124a3883880b37ae3e4290e947c Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 14 May 2026 20:01:03 +0200 Subject: [PATCH 02/37] feat: login to AWS --- .github/workflows/ci.yaml | 45 ++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1a6176c..641f8b7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,12 +1,12 @@ name: CI (test) -on: - push: - branches: - - main - pull_request: - branches: - - main +on: [push] + # push: + # branches: + # - main + # pull_request: + # branches: + # - main jobs: test: @@ -37,4 +37,33 @@ jobs: run: pytest - name: Run linter - run: flake8 . \ No newline at end of file + run: flake8 . + + deploy: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: 01-ci-lab + + permissions: + id-token: write + + needs: test + + steps: + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v6 + with: + role-to-assume: arn:aws:iam::350469506175:role/github-actions-lambda-deploy-role + aws-region: eu-central-1 + + + + + + + + + \ No newline at end of file From 80dc7883fb1b3eaa48206ec7bed6e763887bf0a8 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 14 May 2026 20:02:27 +0200 Subject: [PATCH 03/37] chore: fix formatting --- 01-ci-lab/app/calculator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/01-ci-lab/app/calculator.py b/01-ci-lab/app/calculator.py index e4c9cca..780215c 100644 --- a/01-ci-lab/app/calculator.py +++ b/01-ci-lab/app/calculator.py @@ -5,6 +5,7 @@ def add(a, b): def divide(a, b): return a / b + def lambda_handler(event, context): a = event["a"] b = event["b"] From 705cab14588c1a7af542f6ed1ef5e6b80d776dfa Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 21 May 2026 19:46:08 +0200 Subject: [PATCH 04/37] feat: add prepare lambda package step --- .github/workflows/ci.yaml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 641f8b7..75e55b4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -58,12 +58,9 @@ jobs: with: role-to-assume: arn:aws:iam::350469506175:role/github-actions-lambda-deploy-role aws-region: eu-central-1 - - - - - - - - + + - name: Prepare Lambda package + run: | + cp app/calculator.py lambda_function.py + zip function.zip lambda_function.py \ No newline at end of file From b629ca82e2a2f957b11b74b48baf40c821bfd14a Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 21 May 2026 19:51:00 +0200 Subject: [PATCH 05/37] chore: checkout the code --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 75e55b4..840f779 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -53,6 +53,9 @@ jobs: steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v6 with: From f11587a4f811a1d279a8bc29c962662a57ef1cfa Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 21 May 2026 19:59:49 +0200 Subject: [PATCH 06/37] feat: deploy Lambda --- .github/workflows/ci.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 840f779..b0f2c09 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -66,4 +66,13 @@ jobs: run: | cp app/calculator.py lambda_function.py zip function.zip lambda_function.py + + - name: Deploy Lambda + run: | + aws lambda update-function-code \ + --function-name calculator-app \ + --zip-file fileb://function.zip + + + \ No newline at end of file From d6700771cc827543bc7b555c7bfa55f6d0a7b221 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 21 May 2026 20:07:59 +0200 Subject: [PATCH 07/37] feat: add multiply --- 01-ci-lab/app/calculator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/01-ci-lab/app/calculator.py b/01-ci-lab/app/calculator.py index 780215c..cd292bd 100644 --- a/01-ci-lab/app/calculator.py +++ b/01-ci-lab/app/calculator.py @@ -6,6 +6,10 @@ def divide(a, b): return a / b +def multiply(a, b): + return a * b + + def lambda_handler(event, context): a = event["a"] b = event["b"] From 9ec1505445e3a7dde54efca874a3c16a05311cf7 Mon Sep 17 00:00:00 2001 From: Agata Skorupka <45850123+askorupka@users.noreply.github.com> Date: Thu, 4 Jun 2026 14:40:52 +0200 Subject: [PATCH 08/37] fix: update lambda_handler to handle JSON input and outputfix Refactor lambda_handler to parse JSON body and return results in JSON format. --- 01-ci-lab/app/calculator.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/01-ci-lab/app/calculator.py b/01-ci-lab/app/calculator.py index cd292bd..9ea1b07 100644 --- a/01-ci-lab/app/calculator.py +++ b/01-ci-lab/app/calculator.py @@ -1,3 +1,6 @@ +import json + + def add(a, b): return a + b @@ -11,19 +14,23 @@ def multiply(a, b): def lambda_handler(event, context): - a = event["a"] - b = event["b"] + body = json.loads(event["body"]) - operation = event["operation"] + a = body["a"] + b = body["b"] + operation = body["operation"] if operation == "add": result = add(a, b) elif operation == "divide": result = divide(a, b) else: - return {"statusCode": 400, "body": "Unsupported operation"} + return { + "statusCode": 400, + "body": json.dumps({"error": "Unsupported operation"}) + } return { "statusCode": 200, - "body": result + "body": json.dumps({"result": result}) } From 2d3aef47a51f0b37d81564f8312c298754bffe70 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 4 Jun 2026 19:30:44 +0200 Subject: [PATCH 09/37] chore: upgrade checkout step version --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b0f2c09..edd2578 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,7 +23,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v6 - name: Setup python uses: actions/setup-python@v4 @@ -54,7 +54,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v6 - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v6 From 0823fc8da0926b6fd42e3b69134f5d4771b5eee7 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 4 Jun 2026 19:34:21 +0200 Subject: [PATCH 10/37] chore: upgrade setup-python --- .github/workflows/ci.yaml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index edd2578..0ffe205 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,7 +26,7 @@ jobs: uses: actions/checkout@v6 - name: Setup python - uses: actions/setup-python@v4 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} @@ -71,8 +71,4 @@ jobs: run: | aws lambda update-function-code \ --function-name calculator-app \ - --zip-file fileb://function.zip - - - - \ No newline at end of file + --zip-file fileb://function.zip \ No newline at end of file From 1a97d9138c6caf8600df0604576c6767f32c30a5 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 4 Jun 2026 19:46:46 +0200 Subject: [PATCH 11/37] fix: create lambda function --- .github/workflows/ci.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0ffe205..457448f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -67,6 +67,14 @@ jobs: cp app/calculator.py lambda_function.py zip function.zip lambda_function.py + - name: Create Lambda + run: | + aws lambda create-function \ + --function-name calculator-app \ + --role arn:aws:iam::350469506175:role/service-role/calculator-app-role-cnpkrehb \ + --runtime python3.13 \ + --zip-file fileb://function.zip + - name: Deploy Lambda run: | aws lambda update-function-code \ From 434c9d7930097cb309d8df9ab2acf2399f465965 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 4 Jun 2026 19:49:34 +0200 Subject: [PATCH 12/37] fix: add mandatory parameters --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 457448f..df90c44 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -73,6 +73,7 @@ jobs: --function-name calculator-app \ --role arn:aws:iam::350469506175:role/service-role/calculator-app-role-cnpkrehb \ --runtime python3.13 \ + --handler lambda_function.lambda_handler \ --zip-file fileb://function.zip - name: Deploy Lambda From eb3bcc11dfcbd189787ad0a4673950c24cd4c3a2 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 4 Jun 2026 19:51:49 +0200 Subject: [PATCH 13/37] feat: add multiply support --- 01-ci-lab/app/calculator.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/01-ci-lab/app/calculator.py b/01-ci-lab/app/calculator.py index 9ea1b07..149fd3d 100644 --- a/01-ci-lab/app/calculator.py +++ b/01-ci-lab/app/calculator.py @@ -24,6 +24,8 @@ def lambda_handler(event, context): result = add(a, b) elif operation == "divide": result = divide(a, b) + elif operation == "multiply": + result = multiply(a, b) else: return { "statusCode": 400, From 124ac919285e66568b1c0c972c357863ad5556bd Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 4 Jun 2026 20:01:05 +0200 Subject: [PATCH 14/37] fix: create/update lambda function conditionally --- .github/workflows/ci.yaml | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index df90c44..1493fff 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -67,17 +67,25 @@ jobs: cp app/calculator.py lambda_function.py zip function.zip lambda_function.py - - name: Create Lambda + - name: Create/update Lambda run: | - aws lambda create-function \ - --function-name calculator-app \ - --role arn:aws:iam::350469506175:role/service-role/calculator-app-role-cnpkrehb \ - --runtime python3.13 \ - --handler lambda_function.lambda_handler \ - --zip-file fileb://function.zip - - - name: Deploy Lambda - run: | - aws lambda update-function-code \ - --function-name calculator-app \ - --zip-file fileb://function.zip \ No newline at end of file + if aws lambda get-function --function-name calculator-app >/dev/null 2>&1; then + + echo "calculator-app lambda exists" + + aws lambda update-function-code \ + --function-name calculator-app \ + --zip-file fileb://function.zip + + else + + echo "calculator-app lambda doesn't exist, creating" + + aws lambda create-function \ + --function-name calculator-app \ + --role arn:aws:iam::350469506175:role/service-role/calculator-app-role-cnpkrehb \ + --runtime python3.13 \ + --handler lambda_function.lambda_handler \ + --zip-file fileb://function.zip + + fi From f8cd10c6b1984406b2d0db101de8e27da3c11b3d Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 11 Jun 2026 14:42:30 +0200 Subject: [PATCH 15/37] fix: update function code to support both curl and AWS console test --- 01-ci-lab/app/calculator.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/01-ci-lab/app/calculator.py b/01-ci-lab/app/calculator.py index 149fd3d..7a2638f 100644 --- a/01-ci-lab/app/calculator.py +++ b/01-ci-lab/app/calculator.py @@ -14,10 +14,15 @@ def multiply(a, b): def lambda_handler(event, context): - body = json.loads(event["body"]) + # Function URL / API Gateway + if "body" in event: + body = json.loads(event["body"]) if isinstance(event["body"], str) else event["body"] + # Test from AWS console + else: + body = event - a = body["a"] - b = body["b"] + a = float(body["a"]) + b = float(body["b"]) operation = body["operation"] if operation == "add": @@ -35,4 +40,4 @@ def lambda_handler(event, context): return { "statusCode": 200, "body": json.dumps({"result": result}) - } + } \ No newline at end of file From a1943afd49e456359036a2d3e257cc8e2b3a6fdc Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 11 Jun 2026 14:43:26 +0200 Subject: [PATCH 16/37] chore: test Lambda URL creation --- .github/workflows/ci.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1493fff..db87e69 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -89,3 +89,21 @@ jobs: --zip-file fileb://function.zip fi + + - name: Create Lambda URL + run: | + if ! aws lambda get-function-url-config \ + --function-name calculator-app >/dev/null 2>&1; then + + aws lambda create-function-url-config \ + --function-name calculator-app \ + --auth-type NONE + + aws lambda add-permission \ + --function-name calculator-app \ + --statement-id FunctionURLAllowPublicAccess \ + --action lambda:InvokeFunctionUrl \ + --principal "*" \ + --function-url-auth-type NONE + + fi \ No newline at end of file From e1511d34de008b59d93a1fded4c9918ba919803f Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 11 Jun 2026 14:46:06 +0200 Subject: [PATCH 17/37] fix: update code --- 01-ci-lab/app/calculator.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/01-ci-lab/app/calculator.py b/01-ci-lab/app/calculator.py index 7a2638f..046c4a6 100644 --- a/01-ci-lab/app/calculator.py +++ b/01-ci-lab/app/calculator.py @@ -16,8 +16,11 @@ def multiply(a, b): def lambda_handler(event, context): # Function URL / API Gateway if "body" in event: - body = json.loads(event["body"]) if isinstance(event["body"], str) else event["body"] - # Test from AWS console + if isinstance(event["body"], str): + body = json.loads(event["body"]) + else: + body = event["body"] + # Test from AWS Console else: body = event @@ -40,4 +43,4 @@ def lambda_handler(event, context): return { "statusCode": 200, "body": json.dumps({"result": result}) - } \ No newline at end of file + } From a5b262790b268657b4086842a622f5be8a90aeb0 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 11 Jun 2026 14:56:12 +0200 Subject: [PATCH 18/37] fix: add more permissions to lambda function --- .github/workflows/ci.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index db87e69..19085ae 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -106,4 +106,18 @@ jobs: --principal "*" \ --function-url-auth-type NONE + aws lambda add-permission \ + --function-name calculator-app \ + --statement-id FunctionURLAllowPublicAccess \ + --action lambda:InvokeFunctionUrl \ + --principal "*" \ + --function-url-auth-type NONE || true + + aws lambda add-permission \ + --function-name calculator-app \ + --statement-id FunctionURLAllowInvokeAction \ + --action lambda:InvokeFunction \ + --principal "*" \ + --invoked-via-function-url true || true + fi \ No newline at end of file From 498803b8cff2ff796bcb920f92660412cc32f9f8 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 11 Jun 2026 14:58:58 +0200 Subject: [PATCH 19/37] fix: add more permissions to lambda function --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 19085ae..fb208f6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -108,14 +108,14 @@ jobs: aws lambda add-permission \ --function-name calculator-app \ - --statement-id FunctionURLAllowPublicAccess \ + --statement-id FunctionAllowPublicAccess \ --action lambda:InvokeFunctionUrl \ --principal "*" \ --function-url-auth-type NONE || true aws lambda add-permission \ --function-name calculator-app \ - --statement-id FunctionURLAllowInvokeAction \ + --statement-id FunctionAllowInvokeAction \ --action lambda:InvokeFunction \ --principal "*" \ --invoked-via-function-url true || true From c4a39ec28405549245da70bf76245a0712ecef28 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 11 Jun 2026 15:00:28 +0200 Subject: [PATCH 20/37] fix: add more permissions to lambda function --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fb208f6..0679676 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -101,7 +101,7 @@ jobs: aws lambda add-permission \ --function-name calculator-app \ - --statement-id FunctionURLAllowPublicAccess \ + --statement-id FunctionAllowPublicAccess \ --action lambda:InvokeFunctionUrl \ --principal "*" \ --function-url-auth-type NONE From dd0660cbcaff0648030f29d5a35ca907b5e392e8 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 11 Jun 2026 15:09:06 +0200 Subject: [PATCH 21/37] fix: add more permissions to lambda function --- .github/workflows/ci.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0679676..a0a173a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -106,13 +106,6 @@ jobs: --principal "*" \ --function-url-auth-type NONE - aws lambda add-permission \ - --function-name calculator-app \ - --statement-id FunctionAllowPublicAccess \ - --action lambda:InvokeFunctionUrl \ - --principal "*" \ - --function-url-auth-type NONE || true - aws lambda add-permission \ --function-name calculator-app \ --statement-id FunctionAllowInvokeAction \ From aaed6784b0a85bdbe421f05dcf58d902d8eccfc5 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 11 Jun 2026 15:13:19 +0200 Subject: [PATCH 22/37] fix: add more permissions to lambda function --- .github/workflows/ci.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a0a173a..aa6f58c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -99,13 +99,6 @@ jobs: --function-name calculator-app \ --auth-type NONE - aws lambda add-permission \ - --function-name calculator-app \ - --statement-id FunctionAllowPublicAccess \ - --action lambda:InvokeFunctionUrl \ - --principal "*" \ - --function-url-auth-type NONE - aws lambda add-permission \ --function-name calculator-app \ --statement-id FunctionAllowInvokeAction \ From 53295c2a2a718c20da1c058b9c14d54ea45e6c75 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 11 Jun 2026 15:14:23 +0200 Subject: [PATCH 23/37] fix: add more permissions to lambda function --- .github/workflows/ci.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index aa6f58c..a78f9b3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -99,11 +99,18 @@ jobs: --function-name calculator-app \ --auth-type NONE + aws lambda add-permission \ + --function-name calculator-app \ + --statement-id FunctionAllowPublicAccess \ + --action lambda:InvokeFunctionUrl \ + --principal "*" \ + --function-url-auth-type NONE + aws lambda add-permission \ --function-name calculator-app \ --statement-id FunctionAllowInvokeAction \ --action lambda:InvokeFunction \ --principal "*" \ - --invoked-via-function-url true || true + --invoked-via-function-url true fi \ No newline at end of file From 1afc26ccb8cf3ff5b4370556362a20a4e9c6b702 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 11 Jun 2026 15:21:30 +0200 Subject: [PATCH 24/37] fix: add more permissions to lambda function --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a78f9b3..bf5f39b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -111,6 +111,6 @@ jobs: --statement-id FunctionAllowInvokeAction \ --action lambda:InvokeFunction \ --principal "*" \ - --invoked-via-function-url true + --invoked-via-function-url fi \ No newline at end of file From 97c953e15a36f0e60d0132379096cda6566f16cd Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 11 Jun 2026 15:27:10 +0200 Subject: [PATCH 25/37] chore: cleanup code --- .github/workflows/ci.yaml | 25 ------------------------- 01-ci-lab/app/calculator.py | 4 ++-- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bf5f39b..1493fff 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -89,28 +89,3 @@ jobs: --zip-file fileb://function.zip fi - - - name: Create Lambda URL - run: | - if ! aws lambda get-function-url-config \ - --function-name calculator-app >/dev/null 2>&1; then - - aws lambda create-function-url-config \ - --function-name calculator-app \ - --auth-type NONE - - aws lambda add-permission \ - --function-name calculator-app \ - --statement-id FunctionAllowPublicAccess \ - --action lambda:InvokeFunctionUrl \ - --principal "*" \ - --function-url-auth-type NONE - - aws lambda add-permission \ - --function-name calculator-app \ - --statement-id FunctionAllowInvokeAction \ - --action lambda:InvokeFunction \ - --principal "*" \ - --invoked-via-function-url - - fi \ No newline at end of file diff --git a/01-ci-lab/app/calculator.py b/01-ci-lab/app/calculator.py index 046c4a6..397806e 100644 --- a/01-ci-lab/app/calculator.py +++ b/01-ci-lab/app/calculator.py @@ -24,8 +24,8 @@ def lambda_handler(event, context): else: body = event - a = float(body["a"]) - b = float(body["b"]) + a = body["a"] + b = body["b"] operation = body["operation"] if operation == "add": From 4e5cef2e15e29093be994299dd8fd45842811856 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 11 Jun 2026 18:43:35 +0200 Subject: [PATCH 26/37] chore: prepare code for the class --- 01-ci-lab/app/calculator.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/01-ci-lab/app/calculator.py b/01-ci-lab/app/calculator.py index 397806e..766214b 100644 --- a/01-ci-lab/app/calculator.py +++ b/01-ci-lab/app/calculator.py @@ -32,8 +32,6 @@ def lambda_handler(event, context): result = add(a, b) elif operation == "divide": result = divide(a, b) - elif operation == "multiply": - result = multiply(a, b) else: return { "statusCode": 400, From 7336b7cd928722b88ad5fbb96e9d1e166ab33bc2 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 11 Jun 2026 19:43:47 +0200 Subject: [PATCH 27/37] fix: fix types of a and b --- 01-ci-lab/app/calculator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/01-ci-lab/app/calculator.py b/01-ci-lab/app/calculator.py index 766214b..eabb3d5 100644 --- a/01-ci-lab/app/calculator.py +++ b/01-ci-lab/app/calculator.py @@ -24,8 +24,8 @@ def lambda_handler(event, context): else: body = event - a = body["a"] - b = body["b"] + a = float(body["a"]) + b = float(body["b"]) operation = body["operation"] if operation == "add": From 43f5cc9982afe04c3a09ea47dd9e8a2c434fcd75 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 18 Jun 2026 19:39:37 +0200 Subject: [PATCH 28/37] feat: add new operations --- 01-ci-lab/app/calculator.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/01-ci-lab/app/calculator.py b/01-ci-lab/app/calculator.py index eabb3d5..9b1e084 100644 --- a/01-ci-lab/app/calculator.py +++ b/01-ci-lab/app/calculator.py @@ -13,6 +13,10 @@ def multiply(a, b): return a * b +def substract(a, b): + return a - b + + def lambda_handler(event, context): # Function URL / API Gateway if "body" in event: @@ -32,6 +36,10 @@ def lambda_handler(event, context): result = add(a, b) elif operation == "divide": result = divide(a, b) + elif operation == "multiply": + result = multiply(a, b) + elif operation == "substract": + result = substract(a, b) else: return { "statusCode": 400, From aaaf7198860655d425ed8cbd409669f02f93eda7 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Wed, 24 Jun 2026 19:36:27 +0200 Subject: [PATCH 29/37] feat: add function URL --- .github/workflows/ci.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1493fff..63ff831 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -89,3 +89,10 @@ jobs: --zip-file fileb://function.zip fi + + - name: Create function URL + run: | + + aws lambda create-function-url-config \ + --function-name calculator-app \ + --auth-type NONE \ No newline at end of file From 331077623cf4e4bd7904c1637d0c1bd9430b80f3 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Wed, 24 Jun 2026 19:48:11 +0200 Subject: [PATCH 30/37] fix: create URL only when it doesn't exist --- .github/workflows/ci.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 63ff831..73fecc9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -92,7 +92,11 @@ jobs: - name: Create function URL run: | + if ! aws lambda get-function-url-config \ + --function-name calculator-app >/dev/null 2>&1; then - aws lambda create-function-url-config \ - --function-name calculator-app \ - --auth-type NONE \ No newline at end of file + aws lambda create-function-url-config \ + --function-name calculator-app \ + --auth-type NONE + + fi \ No newline at end of file From b15a02ff5e5a789791a466ab153dc8d10076762f Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Wed, 24 Jun 2026 19:57:07 +0200 Subject: [PATCH 31/37] chore: parametrize LAMBDA_NAME --- .github/workflows/ci.yaml | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 73fecc9..17b92c1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -51,6 +51,9 @@ jobs: needs: test + env: + LAMBDA_NAME: calculator-app + steps: - name: Checkout repository @@ -69,20 +72,20 @@ jobs: - name: Create/update Lambda run: | - if aws lambda get-function --function-name calculator-app >/dev/null 2>&1; then + if aws lambda get-function --function-name ${{ env.LAMBDA_NAME }} >/dev/null 2>&1; then - echo "calculator-app lambda exists" + echo "${{ env.LAMBDA_NAME }} lambda exists" aws lambda update-function-code \ - --function-name calculator-app \ + --function-name ${{ env.LAMBDA_NAME }} \ --zip-file fileb://function.zip else - echo "calculator-app lambda doesn't exist, creating" + echo "${{ env.LAMBDA_NAME }} lambda doesn't exist, creating" aws lambda create-function \ - --function-name calculator-app \ + --function-name ${{ env.LAMBDA_NAME }} \ --role arn:aws:iam::350469506175:role/service-role/calculator-app-role-cnpkrehb \ --runtime python3.13 \ --handler lambda_function.lambda_handler \ @@ -93,10 +96,19 @@ jobs: - name: Create function URL run: | if ! aws lambda get-function-url-config \ - --function-name calculator-app >/dev/null 2>&1; then + --function-name ${{ env.LAMBDA_NAME }} >/dev/null 2>&1; then + + echo "URL doesn't exist, creating" aws lambda create-function-url-config \ - --function-name calculator-app \ + --function-name ${{ env.LAMBDA_NAME }} \ --auth-type NONE + else + + echo "URL exists" + + aws lambda get-function-url-config \ + --function-name ${{ env.LAMBDA_NAME }} + fi \ No newline at end of file From 753afc4623b77b880d330aafec441d83baf9b74e Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 2 Jul 2026 20:03:34 +0200 Subject: [PATCH 32/37] fix: add resource-based policy --- .github/workflows/ci.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 17b92c1..9d73dc3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -104,6 +104,20 @@ jobs: --function-name ${{ env.LAMBDA_NAME }} \ --auth-type NONE + aws lambda add-permission \ lambda:InvokeFunction + --function-name ${{ env.LAMBDA_NAME }} \ + --statement-id FunctionAllowPublicAccessUrl \ + --action lambda:InvokeFunctionUrl \ + --principal "*" \ + --function-url-auth-type NONE + + aws lambda add-permission \ + --function-name ${{ env.LAMBDA_NAME }} \ + --statement-id FunctionAllowPublicAccess \ + --action lambda:InvokeFunction \ + --principal "*" \ + --invoked-via-function-url + else echo "URL exists" From 2305cfc9f54f4743fae17eb77f78bf89bf9765cb Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 2 Jul 2026 20:05:08 +0200 Subject: [PATCH 33/37] fix: add resource-based policy --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9d73dc3..782abe2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -104,7 +104,7 @@ jobs: --function-name ${{ env.LAMBDA_NAME }} \ --auth-type NONE - aws lambda add-permission \ lambda:InvokeFunction + aws lambda add-permission \ --function-name ${{ env.LAMBDA_NAME }} \ --statement-id FunctionAllowPublicAccessUrl \ --action lambda:InvokeFunctionUrl \ From 16d24446d3d991839e167dca45869e375bab2e43 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 9 Jul 2026 19:10:46 +0200 Subject: [PATCH 34/37] fix: clean up space at the end of the line --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 782abe2..5ffd0fb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -104,14 +104,14 @@ jobs: --function-name ${{ env.LAMBDA_NAME }} \ --auth-type NONE - aws lambda add-permission \ + aws lambda add-permission \ --function-name ${{ env.LAMBDA_NAME }} \ --statement-id FunctionAllowPublicAccessUrl \ --action lambda:InvokeFunctionUrl \ --principal "*" \ --function-url-auth-type NONE - aws lambda add-permission \ + aws lambda add-permission \ --function-name ${{ env.LAMBDA_NAME }} \ --statement-id FunctionAllowPublicAccess \ --action lambda:InvokeFunction \ From f3e3da88f18980900c831ccfba0174243b5f7faa Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 9 Jul 2026 19:19:27 +0200 Subject: [PATCH 35/37] feat: add power operation --- 01-ci-lab/app/calculator.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/01-ci-lab/app/calculator.py b/01-ci-lab/app/calculator.py index 9b1e084..092f1e6 100644 --- a/01-ci-lab/app/calculator.py +++ b/01-ci-lab/app/calculator.py @@ -17,6 +17,10 @@ def substract(a, b): return a - b +def power(a, b): + return a**b + + def lambda_handler(event, context): # Function URL / API Gateway if "body" in event: @@ -40,6 +44,8 @@ def lambda_handler(event, context): result = multiply(a, b) elif operation == "substract": result = substract(a, b) + elif operation == "power": + result = power(a, b) else: return { "statusCode": 400, From 80d06b8e5646cd8b806f83c55baf4e3313ded534 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 9 Jul 2026 19:25:24 +0200 Subject: [PATCH 36/37] chore: change trigger for GHA --- .github/workflows/ci.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5ffd0fb..c9a4d28 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,12 +1,12 @@ name: CI (test) -on: [push] - # push: - # branches: - # - main - # pull_request: - # branches: - # - main +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: test: From 4e62931625ce4270fe37834d489912511bab25f8 Mon Sep 17 00:00:00 2001 From: Agata Skorupka Date: Thu, 9 Jul 2026 19:37:26 +0200 Subject: [PATCH 37/37] fix: newline at the end of the file --- 01-ci-lab/app/calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01-ci-lab/app/calculator.py b/01-ci-lab/app/calculator.py index a2ecc6c..092f1e6 100644 --- a/01-ci-lab/app/calculator.py +++ b/01-ci-lab/app/calculator.py @@ -55,4 +55,4 @@ def lambda_handler(event, context): return { "statusCode": 200, "body": json.dumps({"result": result}) - } \ No newline at end of file + }