Skip to content

slugger-analytics/slugger-lambda-functions

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ALPB Lambda Functions

This repository contains the AWS Lambda functions used in for ALPB Analytics Platorm, their associated tests, and some additional Python scripts used in the data pipeline.

Developer Instructions

Getting Started

Clone this repository and cd into the root directory.

Copy .env.example to .env and fill in the real values.

(Optional) Creating a virtual environment for your Python lambda function:

  1. cd into your function's directory.
  2. Execute $ python -m venv <my-virtual-env>
  3. Activating your virtual environment - on Linux: source my-virtual-env/bin/activate
    On Windows: .\my-virtual-env\scripts\activate

Deploying a Lambda function to AWS:

I. Via bash script (for Python scripts requiring the Psycopg2 module)

Ensure your lambda function and its dependencies are organized like so:

functions/
└── <your-function_directory>/
    └── venv/                   # virtual environment
    └── lambda_function.py
    └── requirements.txt

Next:

  1. cd into the functions directory.
  2. Run the bash deployment script:
./deploy_lambda_py.sh -f <your_function_on_lambda>

Follow the instructions provided and your code should be deployed!
Note: since the bash script is primarily used to deploy API endpoints that interact with our database, the psycopg2 modules for Python 3.11 will be included in your deployment. Ensure your lambda function has the same runtime.

II. via Docker (for process_trackman)

Ensure Docker engine is running on your machine, and cd into your function's directory (ex: /functions/process_trackman). You can check if your AWS CLI is configured properly by running $ aws sts get-caller-identity

  1. Run $ cdk bootstrap aws://accountId/us-east-2. If you have already successfully run this command with the same account in the same region, you won't need to run it again.
  2. Next, run $ cdk deploy. If everything was successful, your image should be deployed to Lambda!

For more detailed instructions, check out this video.

III. via AWS CLI (for most functions)

For functions with fewer packages that don't require the Psycopg2 module, the AWS CLI is the most efficient method for deployment.

  1. cd into your function directory.
  • Ensure your packages are present in the directory, either via Python virtual environment for by running npm install.
  1. Run zip -r <my-function>.zip . to zup up your function.
  2. Run aws lambda update-function-code --function-name <lambda-function-name> --zip-file fileb://<function-name>.zip.

Your lambda function should be updated now!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.5%
  • Other 0.5%