Code Monkey home page Code Monkey logo

action-lambda-python-zip's Introduction

action-lambda-python-zip

GitHub Action to make zip deployment to AWS Lambda with pip requirements in a separate layer and additional custom layers.

Forked from: GitHubActions

Description

This action automatically installs requirements, zips and deploys the code including the dependencies as a separate layer.

Python 3.7 is supported

Pre-requisites

In order for the Action to have access to the code, you must use the actions/checkout@master job before it.

File Structure

This example workflow assumes your requirements.txt is in the root directory and that your functions are in folders with their function name as the directory name. Custom layers are assumed to be in a directory that matches their custom_layer_N_path value.

The below workflow would publish code to layers (pip and any custom layers) and functions (first_function and second_function), and finally also attach the layers to those updated functions.

For any custom layers, before the files are copied and zipped and uploaded to AWS, any custom script can be executed if it is placed inside the layer folder and named predeploy.sh

Environment variables

Storing credentials as a Github secret is strongly recommended.

  • AWS Credentials AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are required.

Inputs

  • requirements_txt The name/path for the requirements.txt file. Defaults to requirements.txt.
  • pip_layer_arn The ARN for the Lambda layer the dependencies should be pushed to without the version (version will be automatically updated on AWS).
  • custom_layer_1_path Something like a folder of utils which holds all your utility code.
  • custom_layer_1_arn The ARN for the Lambda layer where this utility code will go.
  • custom_layer_2_path Same as above if you need more layers.
  • custom_layer_2_arn Same as above if you need more layers.
  • custom_layer_3_path Same as above if you need more layers.
  • custom_layer_3_arn Same as above if you need more layers.
  • custom_layer_4_path Same as above if you need more layers.
  • custom_layer_4_arn Same as above if you need more layers.
  • public_layer_1_arn The ARN of an external public Lambda layer in case you need one (e.g. https://github.com/keithrozario/Klayers).
  • public_layer_2_arn Same as above if you need more layers.
  • public_layer_3_arn Same as above if you need more layers.
  • public_layer_4_arn Same as above if you need more layers.
  • lambda_function_names The Lambda function names comma separated.
  • aws_region

Example Workflow

on:
  push:
    branches:
      - master
jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@master
    - name: Deploy code to Lambda
      uses: seattleagainstslavery/[email protected]
      with:
        pip_layer_arn: 'YOUR_UNIQUE_ARN:layer:LAYER_NAME'
        custom_layer_1_path: 'utils'
        custom_layer_1_arn: 'YOUR_UNIQUE_ARN:layer:LAYER_NAME'
        lambda_function_names: 'first_function,second_function'
        aws_region: 'us-east-2'
      env:
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

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.