Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ GitHub Action to make zip deployment to AWS Lambda with requirements in a separa
This action automatically installs requirements, zips and deploys the code including the dependencies as a separate layer.

#### Python 3.8 is supported
#### Also supports uploading dependencies greater than 50MB to layer (via s3 buckets)

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

### Structure
- Lambda code should be `lambda_function.py`** unless you want to have a customized file name.
- Lambda code should be `lambda_function.py` unless you want to have a customized file name.
- **Dependencies must be stored in a `requirements.txt`**

### Environment variables
Expand All @@ -32,6 +33,8 @@ Storing credentials as secret is stronly recommended.
- Partial ARN - `123456789012:function:function-name`
- `requirements_txt`
The name/path for the `requirements.txt` file. Defaults to `requirements.txt`.
- `s3_bucket`
Name of S3 bucket to upload dependencies.zip to (for dependencies over 50 MB)

### Example Workflow
```yaml
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ inputs:
lambda_function_name:
description: The Lambda function name. Check the AWS docs/readme for examples.
required: true
s3_bucket:
description: s3 bucket to put deps in
required: false
runs:
using: 'docker'
image: 'Dockerfile'
Expand All @@ -20,6 +23,7 @@ runs:
- ${{ inputs.lambda_layer_arn }}
- ${{ inputs.lambda_function_name }}
- ${{ inputs.lambda_region }}
- ${{ inputs.s3_bucket }}
branding:
icon: 'cloud-lightning'
color: 'white'
color: 'white'
11 changes: 9 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ install_zip_dependencies(){

publish_dependencies_as_layer(){
echo "Publishing dependencies as a layer..."
local result=$(aws lambda publish-layer-version --layer-name "${INPUT_LAMBDA_LAYER_ARN}" --zip-file fileb://dependencies.zip)
if [[ -z ${INPUT_S3_BUCKET} ]]; then
echo "uploading zip directly"
local result=$(aws lambda publish-layer-version --layer-name "${INPUT_LAMBDA_LAYER_ARN}" --zip-file fileb://dependencies.zip)
else
echo "uploading zip to s3"
aws s3 cp ./dependencies.zip "s3://${INPUT_S3_BUCKET}/"
local result=$(aws lambda publish-layer-version --layer-name "${INPUT_LAMBDA_LAYER_ARN}" --content "S3Bucket=${INPUT_S3_BUCKET},S3Key=dependencies.zip")
fi
LAYER_VERSION=$(jq '.Version' <<< "$result")
rm -rf python
rm dependencies.zip
Expand All @@ -41,4 +48,4 @@ deploy_lambda_function(){
}

deploy_lambda_function
echo "Each step completed, check the logs if any error occured."
echo "Each step completed, check the logs if any error occured."