Code Monkey home page Code Monkey logo

lampip's Introduction

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

lampip's People

Contributors

hayashiya18 avatar

Watchers

 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.