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
A GitHub Actions repo for tracking the dummies sending free money to Alex Jones + co.

A GitHub Actions repo for tracking the dummies sending free money to Alex Jones + co.

Egarok 2 Jul 20, 2022
Disco is an extensive and extendable Python 2.x/3.x library for the Discord API.

disco Disco is an extensive and extendable Python 2.x/3.x library for the Discord API. Disco boasts the following major features: Expressive, function

1 Nov 18, 2021
Td-Ameritrade, Tradingview, Webhook, AWS Chalice

TDA-Autobot TDA-Autobot is an automated fire and forget trading mechanism utilizing Alex Golec's(Author) tda-api wrapper, Tradingview webhook alerts,

Kyle Jorgensen 2 Dec 12, 2021
A Python wrapper around the OpenWeatherMap web API

PyOWM A Python wrapper around OpenWeatherMap web APIs What is it? PyOWM is a client Python wrapper library for OpenWeatherMap (OWM) web APIs. It allow

Claudio Sparpaglione 740 Dec 18, 2022
Interact and easily use Google Chat room webhooks.

Chat Webhooks Easily interact and send messages with Google Chat's webhooks feature. This API is small, but should be a nice framework for working wit

BD103 2 Dec 13, 2021
𝐀 𝐔𝐥𝐭𝐢𝐦𝐚𝐭𝐞 𝐓𝐞𝐥𝐞𝐠𝐫𝐚𝐦 𝐁𝐨𝐭 𝐅𝐨𝐫 𝐅𝐨𝐫𝐜𝐢𝐧𝐠 𝐘𝐨𝐮𝐫 𝐆𝐫𝐨𝐮𝐩 𝐌𝐞𝐦𝐛𝐞𝐫𝐬 𝐓𝐨 𝐒𝐮𝐛𝐬𝐜𝐫𝐢𝐛𝐞 𝐘𝐨𝐮𝐫 𝐓𝐞𝐥𝐞𝐠𝐫𝐚𝐦 𝐂𝐡𝐚𝐧𝐧𝐞𝐥

𝐇𝐨𝐰 𝐓𝐨 𝐃𝐞𝐩𝐥𝐨𝐲 For easiest way to deploy this Bot click on the below button 𝐌𝐚𝐝𝐞 𝐁𝐲 𝐒𝐮𝐩𝐩𝐨𝐫𝐭 𝐆𝐫𝐨𝐮𝐩 𝐒𝐨𝐮𝐫𝐜𝐞𝐬 𝐅𝐢𝐧𝐝

Mukesh Solanki 2 Jan 05, 2022
Discord CTF helper bot for CyberErudites

Eruditus - CTF helper bot Eruditus - CTF helper bot About Eruditus is a Discord CTF helper bot built with Python, it was initially designed to be used

Hafidh 34 Dec 30, 2022
hydrotoolbox is a Python script for hydrologic calculations and analysis or by function calls within Python.

hydrotoolbox is a Python script for hydrologic calculations and analysis or by function calls within Python.

Tim Cera 4 Aug 20, 2022
Georeferencing large amounts of data for free.

Geolocate Georeferencing large amounts of data for free. Special thanks to @brunodepauloalmeida and the whole team for the contributions. How? It's us

Gabriel Gazola Milan 23 Dec 30, 2022
Threat Intel Platform for T-POTs

T-Pot 20.06 runs on Debian (Stable), is based heavily on docker, docker-compose

Deutsche Telekom Security GmbH 4.3k Jan 07, 2023
With this program you can work English & Turkish

1 - How Can I Work This? You must have Python compilers in order to run this program. First of all, download the compiler in the link. Compiler 2 - Do

Mustafa Bahadır Doğrusöz 3 Aug 07, 2021
Talon accessibility - Experimental Talon integrations using macOS accessibility APIs

talon_accessibility Experimental Talon integrations using macOS accessibility AP

Phil Cohen 11 Dec 23, 2022
Lambda-function - Python codes that allow notification of changes made to some services using the AWS Lambda Function

AWS Lambda Function This repository contains python codes that allow notificatio

Elif Apaydın 3 Feb 11, 2022
Information about the weather in a city written using Python

Information about the weather in a city Enter the desired city Climate information of the target city This program is written using Python programming

Amir Hussein Sharifnezhad 4 Nov 17, 2021
A simple discord bot based on python

A simple discord bot based on python

SENPAI LEGEND 2 Jul 24, 2022
Rust UserBot, Telegram istifadəsini asanlaşdıran bir proyektdir.

RUST USERBOT 🇦🇿 Rust UserBot, Telegram istifadəsini asanlaşdıran bir proyektdir. Qurulum Heroku Serverə qurulum git clone https://github.com/rustres

1 Oct 25, 2021
Find Roblox Groups & Send To Discord

Roblox-Group-Finder A tool to help you find ownerless roblox groups :) It's really easy, all you need is a discord webhook :) It will not send locked

1 Dec 13, 2021
Discord Rich Presence implementation for Plex.

Perplex Perplex is a Discord Rich Presence implementation for Plex. Features Modern and beautiful Rich Presence for both movies and TV shows The Movie

Ethan 52 Dec 19, 2022
Exporta archivos masivamente del TEC Digital.

TEC Digital Files Exporter Script que permite exportar los archivos de cursos del TEC Digital del Instituto Tecnológico de Costa Rica, debido al borra

Joseph Vargas 22 Apr 08, 2021
Change Discord HypeSquad in few seconds!

a simple python script that change your hypesquad to what house you choose

Ho3ein 5 Nov 16, 2022