A Github Action to deploy AWS Lambda functions written in Python with their dependencies in a separate layer.
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.
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.
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.
requirements.txt
or a similar file (provide the filename explicitly if that's the case).Stored as secrets or env vars, doesn't matter. But also please don't put your AWS keys outside Secrets.
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
lambda_function_name
my-function
arn:aws:lambda:us-west-2:123456789012:function:my-function
123456789012:function:my-function
requirements_txt
The name/path for the requirements.txt
file. Defaults to requirements.txt
.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'