Skip to main content

Simple CLI tool for creating custom python lambda layers

Project description

lampip: Simple CLI tool for creating python custom lambda layers

image image image image


Features

  • Build Python(3.7, 3.8, 3.9)-compatible custom lambda layers using Docker and pip, and push it to AWS.

  • Reduce the package size using some approachs.

    • Byte-Compile (that remove source comments and docstrings).
    • Remove *.dist-info.

Requirements

  • Python3
  • Docker
  • AWS Account

Installation

You can obtain this packages using pip.

$ pip3 install lampip

Then you can use lampip command.

$ lampip --help
Usage: lampip [OPTIONS] COMMAND [ARGS]...

  Simple CLI tool for creating python custom lambda layers

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  deploy  Build and push lambda layer
  new     Create the scaffold

Usage

At the first create the scaffold

$ lampip new science

Go to the generated directory

$ cd science
$ ls
lampip-config.toml  other_resources  requirements.txt

Edit requirements.txt

numpy
scipy
pandas

Edit lampip-config.toml

[lampip]
layername = "science"
description = "numpy, scipy, and pandas"
pyversions = ["3.7", "3.8", "3.9"]

[lampip.shrink]
compile = true
compile_optimize_level = 2
remove_dist_info = true

# [lampip.shrink.plotly]
# remove_jupyterlab_plotly = true
# remove_data_docs = true

Before you deploy the lambda layer, be sure you have AWS credentials configured.

(If you do not configure AWS credentials yet, ...)
$ aws configure
AWS Access Key ID: ?????
AWS Secret Acess Key: ?????
Default region name: ?????

(Option) You can switch the aws credentials using environments variables.

(Case1: Using AWS CLI profile)
$ export AWS_PROFILE="subaccount"

(Case2: Using AWS access key directly)
$ export AWS_ACCESS_KEY_ID=????
$ export AWS_SECRET_ACCESS_KEY=?????
$ export AWS_DEFAULT_REGION=?????

Deploy

$ lampip deploy
Start to make dist/science_1631253196_3.7.zip
...
Publish the custom layer: arn:aws:lambda:ap-northeast-1:XXXXXXXXXXXX:layer:science-py38:1
DONE: dist/science_1631253312_3.8.zip created

$ ls -lh dist
-rw-r--r-- 1 root root 73M  9月 10 23:54 science_1631253254_3.7.zip
-rw-r--r-- 1 root root 73M  9月 10 23:55 science_1631253312_3.8.zip
...


(The --no-upload option suppress uploading zip files)
$ lampip deploy --no-upload

Then you can check deployed layers on AWS Console.

image

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

lampip-0.3.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

lampip-0.3.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file lampip-0.3.0.tar.gz.

File metadata

  • Download URL: lampip-0.3.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.8.2 Linux/5.15.0-1030-azure

File hashes

Hashes for lampip-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0ba167f01f423f1ee4df71246a243fe4b5912da7eb3b52a8e3b3d66b5b953d4f
MD5 e2d239af0c1a636dd20285318be27f63
BLAKE2b-256 532077120c073c38fceeb86d3cc6641112ffa6e8c5480c21c2c5c06c1b2445a6

See more details on using hashes here.

File details

Details for the file lampip-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: lampip-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.8.2 Linux/5.15.0-1030-azure

File hashes

Hashes for lampip-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25da01d70e18b98b16f8566aa2c455a900ba78e1067b7aa4d57e987d32ead95a
MD5 fe08f23abffe0c0d3a574ecdc2bd042b
BLAKE2b-256 5ef17daa793e2a75a8a9a725706f391526f3a7f1248d19ea91f5511cb2d76593

See more details on using hashes here.

Supported by

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