diff --git a/README.md b/README.md index 70f7977..cc977ff 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/action.yml b/action.yml index 008dae2..b1a4f2d 100644 --- a/action.yml +++ b/action.yml @@ -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' @@ -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' \ No newline at end of file + color: 'white' diff --git a/entrypoint.sh b/entrypoint.sh index 56856b5..f779598 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 @@ -41,4 +48,4 @@ deploy_lambda_function(){ } deploy_lambda_function -echo "Each step completed, check the logs if any error occured." \ No newline at end of file +echo "Each step completed, check the logs if any error occured."