Giter Site home page Giter Site logo

lambda's Introduction

Build AWS Lambda deployment packages with Docker

Update

Amazon now provides images for Lambda runtimes on Docker Hub. See amazon/aws-sam-cli-emulation-image-python. It is important to use this specific set of images to avoid missing binaries, which can occur with similar Python 3.x containers from amazon/.

Blog post (includes tips on reducing package size)

An easier way to build AWS Lambda deployment packages — with Docker instead of EC2

Why?

  • build - introduced to build wheels per #2. In theory this should not affect how the environment functions, but in practice use image id 823205fae3ed if you want to be as close to the official lambda environment as possible. On 9/1/21 the build tag has been updated to support the Python3.8 runtime (only).

Example: Python 3.8 deployment package

docker pull quiltdata/lambda

docker run --rm -v $(pwd)/create_table:/io -t \
	-e GIT_REPO quiltdata/lambda \
	bash /io/package.sh
  • Mount /io as a docker volume
    • /io should contain package.sh and your lambda code \
    • /io is where the deployment package, lambda.zip, is written \
  • Pass environment variables with -e
  • --rm so that, for example, secure envs aren't written to disk

Customize

Modify package.sh to suit your own purposes.

Build container

docker build -t quiltdata/lambda .

Clone private GitHub repo in container

Use a personal access token:

git clone https://${TOKEN}@github.com/USER/REPO

lambda's People

Contributors

akarve avatar dimaryaz avatar sir-sigurd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lambda's Issues

Include hidden files in the zip

Without the hidden files some packages will be broken. You gotta change this line to be
zip -r /io/lambda.zip * .[^.]*

Also I'd rather use this as a layer, so we need to zip the files in a python/ directory like so

cd tmp411
zip -r /io/lambda.zip *

cd ..
mv tmp411 python
zip -r /io/lambda-layer.zip python

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.