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.6, 3.7, 3.8)-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.6", "3.7", "3.8"]

[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.6.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 68M  9月 10 23:53 science_1631253196_3.6.zip
-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.2.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

lampip-0.2.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lampip-0.2.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.8.2 Linux/5.8.0-1040-azure

File hashes

Hashes for lampip-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2ccd8153eb28b8f7e51cd7c097f4a02a28db3766a04222370c1bea075c0521ae
MD5 ccfe493f7f72d899d1c3da5ea1f730e7
BLAKE2b-256 e46c7aa5f37f92aefe2e3611b48ca69c5c8a32a5b93bcfc589e3eaabf90e8171

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lampip-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.8.2 Linux/5.8.0-1040-azure

File hashes

Hashes for lampip-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f6ab54253099f27a13dea623f8e038e1a3f12fe8f98196bf28fadfae4fd632b
MD5 5c99ad07692cb2cd0bb48fae3792e345
BLAKE2b-256 3bcda216474495722858df32dda3a18d828ee76e9ee32dc7fe9fc383101598f7

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