Giter Site home page Giter Site logo

lambda-layer-builder's Introduction

Hands-on AWS

AWS Lambda Layer Builder

A docker-based utility to create lambda layer packages for Python runtime on demand.

Prerequisites

  • Docker desktop

Steps

Clone this repo & follow the steps in windows-commands.bat

  1. Build Docker Image from Dockerfile

    docker build -t layer-builder-image .
    
  2. Run a Container from the Image

    docker run -td --name=layer-builder layer-builder-image
    
  3. Update requirements.txt (local) to list the libraries and versions your project needs. Example:

    pandas==1.4.2
    requests==2.27.1
    
  4. Copy requirements.txt from host to container

    docker cp .\requirements.txt layer-builder:/
    
  5. Run install.sh inside the container

    docker exec -i layer-builder /bin/bash < ./install.sh
    
  6. This script performs the following steps:

    • creates and activates a python virtualenv
    • installs the requested libraries (requirements.txt) from pip
    • creates a zip file named python.zip with all installed packages
  7. Copy the python.zip thus created from container to host

    docker cp layer-builder:/python.zip python.zip
    
  8. Stop and delete the container

    docker stop layer-builder
    docker rm layer-builder
    
  9. โš ๏ธDo NOT rename the zip file. AWS Lambda needs the file to be named python.zip. This zip file can be uploaded to AWS console when creating a new AWS Lambda Layer.

    ๐Ÿ’ก Tip: For storing the zip file for future usage, since you cannot rename the zip file, you can instead create a folder with a descriptive name that describes the contents of the python.zip and move the zip file to that folder. You may also choose to place the requirements.txt file that was used to generate that zip file alongside the zip in same folder.

lambda-layer-builder's People

Contributors

handsonaws avatar

Stargazers

Deba avatar

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.