Sign inSign up

amphio/bootlambda

By amphio

•Updated almost 9 years ago

Dockerised apps for building, running, testing and deploying lambda functions.

Image
0

5.0K

amphio/bootlambda repository overview

⁠Bootlambda

Dockerised apps for building, running, testing and deploying AWS Lambda functions.

  • run functions and tests locally with Docker
  • easily deploy AWS lambda ready binaries
  • plays nicely with CircleCI 2.0

⁠Languages

Python 2.7 and 3.6 are currently supported. The latest Docker images are available from the amphio/bootlambda⁠ Dockerhub repository.

⁠Setup

cd to a directory containing your lambda app structured as followed:

- app/
  - __init__.py
  - lambda_funcion.py
  - other_module.py
  - test_other_module.py
- requirements.txt
- lambda-config.list

..then

docker run -it --rm \
  -v ${PWD}/app:/usr/src/app/app \
  -v ${PWD}/requirements.txt:/usr/src/app/requirements.txt \
  --env-file ./lambda-config.list \
  amphio/bootlambda:py3.6-v0.1.2

This will pull the bootlambda image from here⁠. You should now be inside the container at a shell prompt looking something like this: root@18e941d745dd:/usr/src/app#

⁠Commands

⁠Dev commands

Once setup, you can build your lambda app with dependencies

bash bootlambda.sh build-dev

Import latest code changes then run tests and call main function app

bash bootlambda.sh run-dev

Run your unittests prefixed test_ in app/

bash bootlambda.sh test-dev
⁠Production/CI commands

Once setup, you can build your lambda app with dependencies

bash bootlambda.sh build

To run the app with variables defined in lambda-config.list

bash bootlambda.sh run

To run your unittests prefixed test_ in app/

bash bootlambda.sh test

To zip up your code and deploy it to AWS

bash bootlambda.sh deploy <name of S3 bucket> <name of lambda function> 
⁠Unit tests

These should be stored in app/ directory with filename of form:

test_<some module>.py
e.g.
test_controly.py
⁠Deployment

Images are hosted on dockerhub [here]((https://hub.docker.com/r/amphio/bootlambda/⁠):

cd <this dir>

# Python 2.7
docker build -t amphio/bootlambda:py2.7-<version> ./python2.7
docker push amphio/bootlambda:py2.7-<version>

# Python 3.6
docker build -t amphio/bootlambda:py3.6-<version> ./python3.6
docker push amphio/bootlambda:py3.6-<version>
⁠Dependencies
  • docker
⁠References
  • Liz Rice shows why building lambda binaries in linux is important here⁠
  • lambci/docker-lambda⁠ goes further in emulating lambda logs and environment variables, but the docker containers are complex, it's not clear what source code is in the base container, and doesn't play nicely with CircleCI 2.0

Tag summary

Content type

Image

Digest

Size

374.2 MB

Last updated

almost 9 years ago

docker pull amphio/bootlambda:py3.6-v0.1.31