GitHub Action to make zip deployment to AWS Lambda with requirements in a separate layer.
This action automatically installs requirements, zips and deploys the code including the dependencies as a separate layer.
In order for the Action to have access to the code, you must use the actions/checkout@master
job before it.
- Lambda code should be
lambda_function.py
** unless you want to have a customized file name. - Dependencies must be stored in a
requirements.txt
Storing credentials as secret is stronly recommended.
- AWS Credentials
AWS_ACCESS_KEY_ID
,AWS_SECRET_ACCESS_KEY
,REGION
are required.
lambda_region
lambda_layer_arn
The ARN for the Lambda layer the dependencies should be pushed to without the version (version will be automatically updated on AWS).lambda_function_name
The Lambda function name. From the AWS docs, it can be any of the following:- Function name -
function-name
- Function ARN -
arn:aws:lambda:us-west-2:123456789012:function:function-name
- Partial ARN -
123456789012:function:function-name
- Function name -
requirements_txt
The name/path for therequirements.txt
file. Defaults torequirements.txt
.
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Deploy code to Lambda
uses: qubitro/[email protected]
with:
lambda_layer_arn: 'arn:aws:lambda:eu-central-1:222222222222:layer:layer-name'
lambda_function_name: ${{ secrets.LAMBDA_FUNCTION_NAME }}
lambda_region: 'eu-central-1'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}