-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
114 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Build, Push and Deploy Docker Image to Lambda | ||
|
||
on: | ||
push: | ||
branches: [prod] | ||
|
||
env: | ||
AWS_REGION: ap-southeast-1 | ||
ECR_REPOSITORY: lambda-application-versions-prod | ||
ECR_REPOSITORY_URI: 892404399729.dkr.ecr.ap-southeast-1.amazonaws.com | ||
LAMBDA_FUNCTION_NAME: greendot-analytics | ||
|
||
defaults: | ||
run: | ||
working-directory: ./lambda | ||
|
||
jobs: | ||
build-push-deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_PROD }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_PROD }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} | ||
run: | | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:lambda_${{github.run_number}} . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:lambda_${{github.run_number}} | ||
# - name: Update Lambda function to new image | ||
# run: | | ||
# aws lambda update-function-code \ | ||
# --function-name ${{ env.LAMBDA_FUNCTION_NAME }} \ | ||
# --image-uri $ECR_REGISTRY/$ECR_REPOSITORY:lambda_${{github.run_number}} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Define the base image. AWS provides base images for lambda with different runtimes | ||
FROM public.ecr.aws/lambda/python:3.11 | ||
|
||
# Copy the function code and requirements file into the container | ||
COPY lambda_function.py ${LAMBDA_TASK_ROOT} | ||
COPY requirements.txt ${LAMBDA_TASK_ROOT} | ||
|
||
# Install the Python dependencies from requirements.txt | ||
RUN pip install -r requirements.txt | ||
|
||
# Set the CMD to your handler (could be a different file name and/or a different function) | ||
CMD ["lambda_function.lambda_handler"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import json | ||
import numpy as np | ||
import os | ||
from supabase import create_client | ||
|
||
SUPABASE_URL = os.environ.get("SUPABASE_URL") | ||
SUPABASE_KEY = os.environ.get("SUPABASE_KEY") | ||
db = create_client(SUPABASE_URL, SUPABASE_KEY) | ||
|
||
def lambda_handler(event, context): | ||
temp = event.get('temp') | ||
humidity = event.get('humidity') | ||
flame = event.get('flame') | ||
air_quality = event.get('airQuality') | ||
array1 = np.array([1, 2, 3, 4, 5]); | ||
array2 = np.array([5, 4, 3, 2, 1]); | ||
coef = np.corrcoef(array1, array2) | ||
return { | ||
'statusCode': 200, | ||
'body': json.dumps({ | ||
'probability': 0.5, | ||
'temp': temp, | ||
'humidity': humidity, | ||
'flame': flame, | ||
'airQuality': air_quality, | ||
'coef': [ | ||
coef[0][1], coef[1][0], | ||
], | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
annotated-types==0.6.0 | ||
anyio==4.1.0 | ||
certifi==2023.11.17 | ||
deprecation==2.1.0 | ||
gotrue==1.3.0 | ||
h11==0.14.0 | ||
httpcore==0.17.3 | ||
httpx==0.24.1 | ||
idna==3.4 | ||
numpy==1.26.2 | ||
packaging==23.2 | ||
postgrest==0.13.0 | ||
pydantic==2.5.2 | ||
pydantic_core==2.14.5 | ||
python-dateutil==2.8.2 | ||
realtime==1.0.0 | ||
six==1.16.0 | ||
sniffio==1.3.0 | ||
storage3==0.7.0 | ||
StrEnum==0.4.15 | ||
supabase==2.1.0 | ||
supafunc==0.3.1 | ||
typing_extensions==4.8.0 | ||
websockets==10.4 |