Lamblayer: a minimal deployment tool for AWS Lambda layers

Overview

lamblayer

lamblayer is a minimal deployment tool for AWS Lambda layers.

lamblayer does,

  • Create a Layers of built pip-installable python packages.
  • Create a Layers from local directory.
  • Update function Layers.

That's all.

Install

pip

$ pip install git+https://github.com/YU-SUKETAKAHASHI/[email protected]

Github Actions

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - uses: YU-SUKETAKAHASHI/[email protected]
        with:
          version: v0.1.0
      - run: |
          lamblayer set

Quick start

Try migrate your existing Lambda function quick_start.

$ mkdir quick_start
$ cd quick-start
$ lamblayer init --function-name quick_start
2021-12-24 10:13:41,225: [INFO]: lamblayer : v0.1.0
2021-12-24 10:13:42,132: [INFO]: starting init quick_start
2021-12-24 10:13:42,318: [INFO]: createing function.json
2021-12-24 10:13:42,319: [INFO]: completed

Now you can set layer to quick_start fuction using lamblayer set.

$ lamblayer set
2021-12-24 10:23:34,041: [INFO]: lamblayer : v0.3.0
2021-12-24 10:23:35,312: [INFO]: starting set layers to quick_start
2021-12-24 10:23:35,723: [INFO]: completed

Usage

Usage: lamblayer [OPTIONS] COMMAND [ARGS]...

  lamblayer : v0.1.0

  lamblayer is a minimal deployment tool for AWS Lambda Layers.

Options:
  --profile TEXT                  AWS credential profile
  --region TEXT                   AWS region
  --log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]
                                  log level  [default: (INFO)]
  --help                          Show this message and exit.

Commands:
  create   create a layer.
  init     initialize function.json
  list     show list of the layers.
  set      set layers to function.
  version  show lamblayer's version number.

Init

Initialize set_layer.json by existing function.

Usage: lamblayer init [OPTIONS]

  initialize function.json

Options:
  --profile TEXT                  AWS credential profile
  --region TEXT                   AWS region
  --log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]
                                  log level
  --function-name TEXT            function name for initialize  [default:
                                  LAMBLAYER]
  --download                      download all layers.zip, or not  [default:
                                  False]
  --help                          Show this message and exit.

lamblayer init create set_layer.json as a configration file for layers of the function.

lamblayer init --function-name your_function_name

If --download is selected, download all layer zip contents at ./{layer_name}-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.zip

Create

Create a layer of built pip-installable python packages, or from local directory.

Usage: lamblayer create [OPTIONS]

  create a layer.

Options:
  --profile TEXT                  AWS credential profile
  --region TEXT                   AWS region
  --log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]
                                  log level
  --packages TEXT                 packages file path  [default:
                                  (packages.json)]
  --src TEXT                      a root directory to put in the layer.
                                  [default: (.)]
  --wrap-dir1 TEXT                a wrap directory1 name
  --wrap-dir2 TEXT                a wrap directory2 name
  --layer TEXT                    layer config file  [default: layer.json]
  --help                          Show this message and exit.
  1. pip-installable packages

Creating a layer of pip-installable python packages, spesify packages config file with --packages, and layer config file with --layer.

lamblayer create --packages packages.json --layer layer.json

Note: This option is currently not available. Coming soon!!

  1. from local directory

Creating a layer from local directory, spesify src directory with --src, and layer config file with --layer.

lamblayer create --src my_packages --layer.json

In layers, you have to place script files in the python directory, but lamblayer can handle the placing for you. You can wrap your package using --wrap-dir1 and --wrap-dir2.

ex1)

your dir tree,

.
├── layer.json
└── my_package
    ├── __init__.py
    ├── module1.py
    └── module2.py

command,

lamblayer create --src my_package --wrap-dir1 python

now, created layer dir tree.

python
├── __init__.py
├── module1.py
└── module2.py

ex2)

your dir tree,

.
├── layer.json
└── my_package
    ├── __init__.py
    ├── module1.py
    └── module2.py

command,

lamblayer create --src my_package --wrap-dir1 python --wrap-dir2 my_package

now, created layer dir tree.

python
└── my_package
    ├── __init__.py
    ├── module1.py
    └── module2.py

packages.json

packages.json is a difinition for LayerZip. These attributes will be used for LayerZip API call.

{
    "Arch": "x86_64",
    "Runtime": "py39",
    "Packages": [
        "numpy==1.20.2",
        "requests"
    ]
}

Arch (string): the instruction set architecture you want for your function code. [x86_64 | arm64]

Runtime (string): the language of your lambda that uses this layer. [py37 | py38 | py39]

Packages (list, string): the pip-installable packages name. You can specify version of package in the same way as pip install.

layer.json

layer.json is a definition for Lambda layers. JSON structure is based from PublishLayerVersion for Lambda API.

{
    "LayerName": "numpy_requests",
    "Description": "numpy==1.20.2, requests",
    "CompatibleRuntimes": [
        "python3.7",
        "python3.8",
        "python3.9"
    ],
    "LicenseInfo": ""
}

Set

Set layers to the function.

Usage: lamblayer set [OPTIONS]

  set layers to function.

Options:
  --profile TEXT                  AWS credential profile
  --region TEXT                   AWS region
  --log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]
                                  log level
  --function TEXT                 function config file  [default:
                                  function.json]
  --help                          Show this message and exit.

lamblayer set changes the configration of the function for layers.

lamblayer set --set-layer set_layer.json

function.json

function.json is a definition for Lambda function. JSON structure is part of CreateFunction for Lambda API.

{
    "FunctionName": "lamblayer",
    "Layers": [
        "arn:aws:lambda:ap-northeast-1:xxxxxxxxxxxx:layer:Galaxy:42",
        "lamblayer_layer"
    ]
}

If the name of layer is only passed, completes it to the ARN(Amazon Resourse Name) with the latest version number.

ex) arn:aws:lambda:{your_region}:{your_accountid}:layer:lambdarider_layer:{latest_version_number}

List

Show List of the layers.

Usage: lamblayer list [OPTIONS]

  show list of the layers.

Options:
  --profile TEXT                  AWS credential profile
  --region TEXT                   AWS region
  --log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]
                                  log level
  --help                          Show this message and exit.
lamblayer list

LICENSE

MIT License

Copyright© 2021 Yusuke Takahashi

You might also like...
Automated AWS account hardening with AWS Control Tower and AWS Step Functions
Automated AWS account hardening with AWS Control Tower and AWS Step Functions

Automate activities in Control Tower provisioned AWS accounts Table of contents Introduction Architecture Prerequisites Tools and services Usage Clean

Implement backup and recovery with AWS Backup across your AWS Organizations using a CI/CD pipeline (AWS CodePipeline).
Implement backup and recovery with AWS Backup across your AWS Organizations using a CI/CD pipeline (AWS CodePipeline).

Backup and Recovery with AWS Backup This repository provides you with a management and deployment solution for implementing Backup and Recovery with A

Criando Lambda Functions para Ingerir Dados de APIs com AWS CDK

LIVE001 - AWS Lambda para Ingerir Dados de APIs Fazer o deploy de uma função lambda com infraestrutura como código Lambda vai numa API externa e extra

A python library for creating Slack slash commands using AWS Lambda Functions

slashbot Slashbot makes it easy to create slash commands using AWS Lambda functions. These can be handy for creating a secure way to execute automated

AWS SQS event redrive Lambda With Python

AWS SQS event redrive Lambda This repository contains one simple AWS Lambda function in Python to redrive AWS SQS events from source queue to destinat

AWS SQS event redrive Lambda

This repository contains the Lambda function to redrive sqs events from source to destination queue while controlling maxRetry per event.

AWS Lambda Fast API starter application

AWS Lambda Fast API Fast API starter application compatible with API Gateway and Lambda Function. How to deploy it? Terraform AWS Lambda API is a reus

A Python AWS Lambda Webhook listener that generates a permanent URL when an asset is created in Contentstack.

Webhook Listener A Python Lambda Webhook Listener - Generates a permanent URL on created assets. See doc on Generating a Permanent URL: https://www.co

AWS Lambda - Parsing Cloudwatch Data and sending the response via email.

AWS Lambda - Parsing Cloudwatch Data and sending the response via email. Author: Evan Erickson Language: Python Backend: AWS / Serverless / AWS Lambda

Releases(v0.1.0)
Owner
Yusuke Takahashi
Yusuke Takahashi
Isobot is originally made by notsniped. This is a remix of iso.bot by archisha.

iso6.9-08122021b-1.2beta Isobot is originally made by notsniped#0002. This is a remix of iso.bot by αrchιshα#5518. isobot6.9 is a Discord bot written

Kamilla Youver 3 Jan 11, 2022
Morpheus is a telegram bot that helps to simplify the process of making custom telegram stickers.

😎 Morpheus is a telegram bot that helps to simplify the process of making custom telegram stickers. As you may know, Telegram's official Sti

Abhijith K S 1 Dec 14, 2022
Upvotes and karma for Discord: Heart 💗 or Crush 💔 a comment to give points to an user, or Star ⭐ it to add it to the Best Of!

🤖 Reto Reto is a community-oriented Discord bot, featuring a karma system, a way to reward the best comments, leaderboards, and so much more! React t

Erik Bianco Vera 3 May 07, 2022
Utility for downloading fanfiction in bulk from the Archive of Our Own

What is this? This is a program intended to help you download fanfiction from the Archive of Our Own in bulk. This program is primarily intended to wo

73 Dec 30, 2022
Unofficial Coinbase Python Library

Unofficial Coinbase Python Library Python Library for the Coinbase API for use with three legged oAuth2 and classic API key usage Version 0.3.0 Requir

George Sibble 104 Dec 01, 2022
Python3 program to control Elgato Ring Light on your local network without Elgato's Control Center software

Elgato Light Controller I'm really happy with my Elgato Key Light from an illumination perspective. However, their control software has been glitchy f

Jeff Tarr 14 Nov 16, 2022
Auto-Rollnumber-sender - Auto Rollnumber sender with python

Auto-Rollnumber-sender The above code fits better on my system but it can vary s

Riya Tripathi 2 Feb 14, 2022
Personal Discord Python Bot based on Discord.py

Personal Discord bot using the discord.py library by Rapptz

2 Dec 14, 2022
A discord nitro generator written in python

VerseGenerator A discord nitro generator written in python Usage ・Fork the repo ・Clone it to replit ・Install the required packages and run it ・Input t

NotDrakezz 4 Nov 13, 2021
Neofetch/pfetch, but for weather

Wfetch Neofetch/pfetch, but for weather Features Information about the weather outside: Weather condition Temperature Humidity Pressure Wind Sunrise-s

G_cat 72 Nov 18, 2022
Simple tool to gather domains from crt.sh using the organization name

Domain Collector: _ _ ___ _ _ _ __| | ___ _ __ ___ __ _(_)_ __ / __\___ | |

Cyber Guy 63 Dec 24, 2022
veez music bot is a telegram music bot project, allow you to play music on voice chat group telegram.

🎶 VEEZ MUSIC BOT Veez Music is a telegram bot project that's allow you to play music on telegram voice chat group. Requirements 📝 FFmpeg NodeJS node

levina 143 Jun 19, 2022
数字货币BTC量化交易系统-实盘行情服务器,虚拟币自动炒币-火币API-币安交易所-量化交易-网格策略。趋势跟踪策略,最简源码,可在线回测,一键部署,可定制的比特币量化交易框架,3年实盘检验!

huobi_intf 提供火币网的实时行情服务器(支持火币网所有交易对的实时行情),自带API缓存,可用于实盘交易和模拟回测。 行情数据,是一切量化交易的基础,可以获取1min、60min、4hour、1day等数据。数据能进行缓存,可以在多个币种,多个时间段查询的时候,查询速度依然很快。 服务框架

dev 258 Sep 20, 2021
Python Library for Accessing the Cohere API

Cohere Python SDK This package provides functionality developed to simplify interfacing with the Cohere API in Python 3. Documentation See the API's d

cohere.ai 42 Jan 03, 2023
Official Python client for the MonkeyLearn API. Build and consume machine learning models for language processing from your Python apps.

MonkeyLearn API for Python Official Python client for the MonkeyLearn API. Build and run machine learning models for language processing from your Pyt

MonkeyLearn 157 Nov 22, 2022
A simple message content sniping Discord bot which you can run yourself! Sniping API pulled from isobot and Arch bot

Discord Snipe Bot This is a bot made with the same message content sniping API from isobot and Arch bot. It's default prefix is -, however you can als

notsniped 5 Aug 11, 2022
Rocks vc Userbot: A Telegram Bot Project That's Allow You To Play Audio And Video Music On Telegram Voice Chat Group

⭐️ Rocks VC Userbot ⭐️ Telegram Userbot To Play Audio And Video Song On VC Chat

Dr Asad Ali 10 Jul 18, 2022
Droplink URL Shortener Bot, deployable to Heroku and Railway.

Droplink-bot Make short link by using Droplink API key. Made by @dakshy. Installation The Easy Way Required Variables BOT_TOKEN: Create a bot using @B

ToonsHub 5 Jun 25, 2022
PyDiscord, a maintained fork of discord.py, is a python wrapper for the Discord API.

discord.py A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. The Future of discord.py Please read the gi

Omkaar 1 Jan 16, 2022