Skip to main content

CLI toolkit for bundling AWS Lambda layers

Project description

License: MIT

LAYERMAKE

layermake is a CLI tool for creating AWS Lambda layers

layermake currently supports creating python, NodeJS, and binary layers.

Requirements

Currently layermake has only been tested on Python >= 3.8

Installation:

git clone or download this repository and install with:

pip install .

The binary should now be installed and can be invoked with:

layermake COMMAND [ARGS]

Usage:

run layermake with one of the following commands:

  • nodejs
  • python
  • binary

layermake nodejs and layermake python support fully interactive layer building if no arguments are passed.

All commands share the following options:

  -n, --name TEXT                 layer name
  -l, --license TEXT              text to include in the license field of the
                                  layer
  --license-file TEXT             file containing license info to include in
                                  the license field of the layer
  -a, --arch [x86_64|arm64]       architectures this layer is compatible with
  --profile TEXT                  AWS profile to use
  -d, --description TEXT          description of the layer
  -v, --verbose                   verbose output

NodeJS bundling

To interactively bundle a NodeJS layer with defaults use: layermake nodejs

All NodeJS bundling options as displayed with layermake nodejs --help

To use a package.json file use the option --manifest or -m:

layermake nodejs -n "my nodejs layer" -r 14.x -m package.json
Usage: layermake nodejs [OPTIONS] [PACKAGES]...

Options:
  -n, --name TEXT                 layer name
  -l, --license TEXT              text to include in the license field of the
                                  layer
  --license-file TEXT             file containing license info to include in
                                  the license field of the layer
  -a, --arch [x86_64|arm64]       architectures this layer is compatible with
  --profile TEXT                  AWS profile to use
  -d, --description TEXT          description of the layer
  -v, --verbose                   verbose output
  -r, --runtime [4.3|6.10|8.10|10.x|12.x|14.x|16.x]
                                  nodejs runtime
  -m, --manifest TEXT             nodejs manifest file (package.json)
  -o, --output TEXT               target output directory  [default: layer]
  --container TEXT                use the provided docker container to build
                                  the layer
  --help                          Show this message and exit.

Python bundling

To interactively bundle a Python layer with defaults use: layermake python

All Python bundling options as displayed with layermake python --help

Usage: layermake python [OPTIONS] [PACKAGES]...

Options:
  -n, --name TEXT              layer name
  -l, --license TEXT           text to include in the license field of the
                               layer
  --license-file TEXT          file containing license info to include in the
                               license field of the layer
  -a, --arch [x86_64|arm64]    architectures this layer is compatible with
  --profile TEXT               AWS profile to use
  -d, --description TEXT       description of the layer
  -v, --verbose                verbose output
  -r, --runtime [3.6|3.7|3.8]  python runtime
  -m, --manifest TEXT          python manifest file (requirements.txt)
  -o, --output TEXT            target output directory  [default: layer]
  --container TEXT             use the provided docker container to build the
                               layer
  --help                       Show this message and exit.

Binary bundling

Binary bundling requires an argument specifying either a build script or a directory where either a makefile exists or one of build, install, layer, build-layer exists (with or without a .sh file extensions). If none of these files are provided, you may pass a custom container command to run instead (e.g. /bin/bash my_script.sh).

When bundling a binary layer, the build script is responsible for installing libraries and binaries inside /opt/bin and/or /opt/lib. These directories are zipped inside Docker after running the build script.

Currently, only Docker images that provide yum package manager are supported as yum is used to install build tools in the base image (defaults to amazonlinux:latest)

To add any prerequisite packages not installed by the build script use the --packages flag to have them installed before bundling.

Example:

layermake binary -n 'GnuPG 2.8' -p zlib gnupg-build.sh
Usage: layermake binary [OPTIONS] [ARTIFACT]...

Options:
  -n, --name TEXT                 layer name
  -l, --license TEXT              text to include in the license field of the
                                  layer
  --license-file TEXT             file containing license info to include in
                                  the license field of the layer
  -a, --arch [x86_64|arm64]       architectures this layer is compatible with
  --profile TEXT                  AWS profile to use
  -d, --description TEXT          description of the layer
  -v, --verbose                   verbose output
  --dockerfile TEXT               use the provided dockerfile for bundling
  -o, --output TEXT               target output directory  [default: layer]
  -w, --workdir TEXT              workdir used when bundling inside the
                                  container  [default: /opt]
  -c, --cmd TEXT                  command executed inside the container;
                                  defaults to executing the build artifact
                                  with /bin/bash
  --base-image TEXT               use the provided base docker image when
                                  compiling the Dockerfile for lambda bundling
                                  [default: amazonlinux:latest]
  -p, --packages TEXT             additional packages to install in the
                                  container; currently only yum is supported
  -r, --runtimes [nodejs|nodejs4.3|nodejs6.10|nodejs8.10|nodejs10.x|nodejs12.x|nodejs14.x|nodejs16.x|java8|java8.al2|java11|python2.7|python3.6|python3.7|python3.8|python3.9|dotnetcore1.0|dotnetcore2.0|dotnetcore2.1|dotnetcore3.1|dotnet6|nodejs4.3-edge|go1.x|ruby2.5|ruby2.7|provided|provided.al2|nodejs18.x|all]
                                  compatible runtimes
  --help                          Show this message and exit.

Todo:

  • comprehensive unit testing
  • rust support
  • java support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

layermake-0.0.1.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

layermake-0.0.1-py2.py3-none-any.whl (13.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file layermake-0.0.1.tar.gz.

File metadata

  • Download URL: layermake-0.0.1.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for layermake-0.0.1.tar.gz
Algorithm Hash digest
SHA256 45fd7d244d58cc4329410bd4a38ce61287bdc04c93efec8d4cd02fa6a2d4075c
MD5 e4c5c742ee30c97cbe97d08f163a0caa
BLAKE2b-256 aa51f3cd8a27c33df4a45ff50a2598d011bae3d221e15ec00a5b135efb8798d4

See more details on using hashes here.

File details

Details for the file layermake-0.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: layermake-0.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for layermake-0.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d2a3fa7c43de44f9fb1e7b4b55a4a65bbae672654c59bb4851f5a01c52c11f02
MD5 32d2a2b0ded5c40f75079932eb416580
BLAKE2b-256 a8f279404a74f882a4b2b5949185345def8e5bb14ec717b85d6a07e801a9a59c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page