From 1afc815362b39c4048fbbde5e4af168718203bfc Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Thu, 24 Aug 2023 10:57:34 +0100 Subject: [PATCH] added the reference to the github sha in the lambda function uri instead of latest --- .github/workflows/deploy_fastapi_backend.yml | 1 + serverless.yml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy_fastapi_backend.yml b/.github/workflows/deploy_fastapi_backend.yml index 24fe7fd7..c246c47b 100644 --- a/.github/workflows/deploy_fastapi_backend.yml +++ b/.github/workflows/deploy_fastapi_backend.yml @@ -91,6 +91,7 @@ jobs: DB_PORT: ${{ steps.set_db_credentials.outputs.db_port }} DB_NAME: ${{ steps.set_db_credentials.outputs.db_name }} ECR_URI: ${{ steps.set_ecr_credentials.outputs.ecr_uri }} + GITHUB_SHA: ${{ github.sha }} run: | # Fetch database credentials from AWS Secrets Manager SECRET_VALUE=$(aws secretsmanager get-secret-value --secret-id ${{ github.ref_name }}/assessment_model/db_credentials --query SecretString) diff --git a/serverless.yml b/serverless.yml index f15924f8..89eb666a 100644 --- a/serverless.yml +++ b/serverless.yml @@ -17,6 +17,7 @@ provider: DB_PASSWORD: ${env:DB_PASSWORD} DB_PORT: ${env:DB_PORT} ECR_URI: ${env:ECR_URI} + GITHUB_SHA: ${env:GITHUB_SHA} # Give lambda access to read from the bucket iam: role: @@ -43,7 +44,7 @@ custom: functions: app: image: - uri: ${env:ECR_URI}:latest + uri: ${env:ECR_URI}:${env:GITHUB_SHA} events: - http: path: /{proxy+}