Lambda service for extracting images from wireless camera trap emails
animl-email-relay is a lambda function that is triggered when an email is copied into an s3 bucket by AWS Simple Email Service. To set up email receiving on SES, follow the instructions here.
Currently, the handler supports emails coming from the following camera makers:
The instructions below assume you have the following tools globally installed:
- Serverless
- Docker
- aws-cli
The name of the profile must be "animl", because that's what
serverles.yml
will be looking for. Good instructions
here.
Note: AWS SES only supports email receiving in a few regions.
mkdir animl-email-relay
cd animl-email-relay
git clone https://github.com/tnc-ca-geo/animl-email-relay.git
cd animl-email-relay
This project runs in a Python Lambda environment, which means that all Python
dependencies must be installed in the OS in which the will be ultimately
executed. To accomplish this we use a Serverless plugin called
serverless-python-requirements
that, on serverless deploy
, spins up a Docker container to mimic the AWS
Lambda Linux OS, downloads any Python requirements defined in
requirements.txt
within the container, and packages them up to be added
to our Lambda deployment package.
The plugin works well for installing Python packages, but we also need to include a Perl executable (exiftool) and its dependencies in the final deployment package, and the serverless-python-requirements plugin doesn't support some functionalty that we need to make that happen out of the box (see issue here). I created a fix and pull request to support this, but until the PR is accepted we have to clone the repo into our project manually from my github profile. So from within the project root directory, execute the following:
mkdir .serverless_plugins
cd .serverless_plugins
git clone --single-branch --branch recursive-docker-extra-files https://github.com/nathanielrindlaub/serverless-python-requirements.git
cd serverless-python-requirements
npm install
Perform the following steps if you need to use new Python packages in the Lambda function.
In the parent directory of this project (one directory above root), run the following:
virtualenv venv --python=python3
source venv/bin/activate
# Example package installs
pip install requests
pip install PyExifTool
pip freeze > requirements.txt
# Deactivate venv when you're done
deactivate
From project root folder (where serverless.yml
lives), run the following to deploy or update the stack:
# Deploy or update a development stack:
serverless deploy --stage dev
# Deploy or update a production stack:
serverless deploy --stage prod
Animl is comprised of a number of microservices, most of which are managed in their own repositories.
Services necessary to run Animl:
Services related to ingesting and processing wireless camera trap data: