Code Monkey home page Code Monkey logo

py-lambda-action's Introduction

py-lambda-action

GitHubActions

A Github Action to deploy AWS Lambda functions written in Python with their dependencies in a separate layer. For now, only works with Python 3.6. PRs welcome.

Use

Deploys everything in the repo as code to the Lambda function, and installs/zips/deploys the dependencies as a separate layer the function can then immediately use.

Pre-requisites

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

Structure

  • Lambda code should be structured normally/as Lambda would expect it.
  • Dependencies must be stored in a requirements.txt or a similar file (provide the filename explicitly if that's the case).

Environment variables

Stored as secrets or env vars, doesn't matter. But also please don't put your AWS keys outside Secrets.

  • AWS Credentials
    That includes the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, etc. It's used by awscli, so the docs for that can be found here.

Inputs

  • lambda_layer_arn
    The ARN for the Lambda layer the dependencies should be pushed to without the version (every push is a new version).
  • lambda_function_name
    The Lambda function name. From the AWS docs, it can be any of the following:
    • Function name - my-function
    • Function ARN - arn:aws:lambda:us-west-2:123456789012:function:my-function
    • Partial ARN - 123456789012:function:my-function

Example workflow

name: deploy-py-lambda
on:
  push:
    branches:
      - master
jobs:
  build:
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@master
    - name: Deploy code to Lambda
      uses: mariamrf/[email protected]
      with:
        lambda_layer_arn: 'arn:aws:lambda:us-east-2:123456789012:layer:my-layer'
        lambda_function_name: 'my-function'
      env:
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        AWS_DEFAULT_REGION: 'us-east-2'

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.