{"id":15866997,"url":"https://github.com/robertpeteuil/build-lambda-layer-python","last_synced_at":"2025-03-16T02:31:15.557Z","repository":{"id":130532315,"uuid":"178622312","full_name":"robertpeteuil/build-lambda-layer-python","owner":"robertpeteuil","description":"Build AWS Lambda Layer zip file for specific version of Python and given requirements.txt","archived":false,"fork":false,"pushed_at":"2020-05-09T01:28:37.000Z","size":7,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-27T04:47:41.476Z","etag":null,"topics":["aws-lambda-layer","aws-lambda-python","lambda","lambda-environment","lambda-layer","lambda-layers","lambda-runtime","lambda-tools","python-dependancies","unnecessary-libraries"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robertpeteuil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-30T23:35:23.000Z","updated_at":"2025-02-07T10:57:41.000Z","dependencies_parsed_at":"2023-04-14T07:54:29.447Z","dependency_job_id":null,"html_url":"https://github.com/robertpeteuil/build-lambda-layer-python","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertpeteuil%2Fbuild-lambda-layer-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertpeteuil%2Fbuild-lambda-layer-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertpeteuil%2Fbuild-lambda-layer-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertpeteuil%2Fbuild-lambda-layer-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertpeteuil","download_url":"https://codeload.github.com/robertpeteuil/build-lambda-layer-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243801675,"owners_count":20350108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda-layer","aws-lambda-python","lambda","lambda-environment","lambda-layer","lambda-layers","lambda-runtime","lambda-tools","python-dependancies","unnecessary-libraries"],"created_at":"2024-10-05T23:40:43.609Z","updated_at":"2025-03-16T02:31:15.033Z","avatar_url":"https://github.com/robertpeteuil.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Build AWS Lambda Layer zip file for Python Dependancies\n\nCreates an AWS Lambda Layers zip file that is **optimized** for: [Lambda Layer directory structure](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-path), compiled library compatibility, and minimal file size.\n\nThis function was created to address these issues:\n\n- Many methods of creating Lambda zip files for Python functions don't work for Lambda Layers\n  - This is due to the fact Lambda Layers require specific library paths within the zip, unlike regular Lambda zip files\n- Compiled dependancies must be created in an environment that matches the Lambda runtime\n- Reduce size of zip file by removing unnecessary libraries and files\n\n**Note: This script requires Docker and uses a container to mimic the Lambda environment.**\n\n## Features\n\n- Builds zip file containing Python dependancies and places the libraries into the proper directory structure for lambda layers\n- Ensures compiled libraries are compatible with Lambda environment by using [docker container](https://hub.docker.com/r/lambci/lambda) that mimics the lambda runtime environment\n- Optimized the zip size by removing `.pyc` files and unnecessary libraries\n- allows specifying lambda supported python versions: 2.7, 3.6, 3.7 and 3.8\n- Automatically searches for requirements.txt file in several locations:\n  - same directory as script\n  - parent directory or script (useful when used as submodule)\n  - function sub-directory of the parent directory\n\n## Installation\n\nThis function can be **cloned** for standalone use, into a parent repo or added as a **submodule**.\n\nClone for standalone use or within a repo:\n\n``` bash\n# If installing into an exisiting repo, navigate to repo dir\ngit clone --depth 1 https://github.com/robertpeteuil/build-lambda-layer-python _build_layer\n```\n\nAlternatively, add as a submodule:\n\n``` bash\ncd {repo root}\ngit submodule add https://github.com/robertpeteuil/build-lambda-layer-python _build_layer\n# Update submodule\ngit submodule update --init --recursive --remote\n```\n\n## Use\n\n- Run the builder with the command `./build_layer.sh`\n  - or `_build_layer/build_layer.sh` if installed in sub-dir\n- It uses the first requirements.txt file found in these locations (in order):\n  - same directory as script\n  - parent directory of script (useful when used as submodule)\n  - function sub-directory of the parent directory (useful when used as submodule)\n- Optionally specify Python Version\n  - `-p PYTHON_VER` - specifies the Python version: 2.7, 3.6, 3.7, 3.8 (default 3.7)\n\n## Reference - remove submodule\n\nIf installed as submodule and need to remove\n\n``` bash\n# Remove the submodule entry from .git/config\ngit submodule deinit -f $submodulepath\n# Remove the submodule directory from the superproject's .git/modules directory\nrm -rf .git/modules/$submodulepath\n# Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule\ngit rm -f $submodulepath\n# remove entry in submodules file\ngit config -f .git/config --remove-section submodule.$submodulepath\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertpeteuil%2Fbuild-lambda-layer-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertpeteuil%2Fbuild-lambda-layer-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertpeteuil%2Fbuild-lambda-layer-python/lists"}