Skip to content
layers

GitHub Action

Py Lambda Deploy

v0.0.2 Latest version
Use latest version
layers

Py Lambda Deploy

Deploy python code to AWS Lambda with dependencies in a separate layer

Installation

Copy and paste the following snippet into your .yml file.

- name: Py Lambda Deploy
  uses: mariamrf/py-lambda-action@v0.0.2
Learn more about this action in mariamrf/py-lambda-action
Choose a version

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.

Use

Doesn't take any arguments. 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.

Structure

  • Lambda code should be structured normally/as Lambda would expect it.
  • Dependencies must be stored in a requirements.txt.

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.
  • 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_FUNCITON_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

workflow "Build & deploy" {
  on = "push"
  resolves = ["py-lambda-deploy"]
}

action "py-lambda-deploy" {
  needs = "Master"
  uses = "mariamrf/py-lambda-action@master"
  secrets = [
    "AWS_ACCESS_KEY_ID",
    "AWS_SECRET_ACCESS_KEY",
    "AWS_DEFAULT_REGION",
    "LAMBDA_FUNCTION_NAME",
    "LAMBDA_LAYER_ARN",
  ]
}

# Filter for master branch
action "Master" {
  uses = "actions/bin/filter@master"
  args = "branch master"
}
You can’t perform that action at this time.