From 964a58e30511a49ea791e81bdef746b0d8ac2132 Mon Sep 17 00:00:00 2001 From: an-nihil00 <32604310+an-nihil00@users.noreply.github.com> Date: Tue, 15 Mar 2022 07:52:00 -0500 Subject: [PATCH 01/10] poll function state before updating layer config --- entrypoint.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 0ffdfed..e193a6f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,16 @@ #!/bin/bash set -e +readonly poll_command=aws lambda get-function --function-name "${INPUT_LAMBDA_FUNCTION_NAME}" --query 'Configuration.[State, LastUpdateStatus]' + +wait_state(){ + echo "Waiting on function state update..." + until ${poll_command} | grep "Active" + do + sleep 1 + done +} + install_zip_dependencies(){ echo "Installing and zipping dependencies..." mkdir python @@ -31,6 +41,7 @@ deploy_lambda_function(){ install_zip_dependencies publish_dependencies_as_layer publish_function_code + wait_state update_function_layers } From ccba71dc6f60afde1e35531d65616adffabd5f46 Mon Sep 17 00:00:00 2001 From: an-nihil00 <32604310+an-nihil00@users.noreply.github.com> Date: Tue, 15 Mar 2022 07:58:27 -0500 Subject: [PATCH 02/10] hopefully fixed problem? --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index e193a6f..04a0a76 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -readonly poll_command=aws lambda get-function --function-name "${INPUT_LAMBDA_FUNCTION_NAME}" --query 'Configuration.[State, LastUpdateStatus]' +poll_command=aws lambda get-function --function-name "${INPUT_LAMBDA_FUNCTION_NAME}" --query 'Configuration.[State, LastUpdateStatus]' wait_state(){ echo "Waiting on function state update..." From 0c3c424e58d1fc6b669a8241dd2376c3543a6521 Mon Sep 17 00:00:00 2001 From: an-nihil00 <32604310+an-nihil00@users.noreply.github.com> Date: Tue, 15 Mar 2022 08:00:46 -0500 Subject: [PATCH 03/10] fixed it for real this time --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 04a0a76..e27d485 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -poll_command=aws lambda get-function --function-name "${INPUT_LAMBDA_FUNCTION_NAME}" --query 'Configuration.[State, LastUpdateStatus]' +poll_command="aws lambda get-function --function-name \"${INPUT_LAMBDA_FUNCTION_NAME}\" --query 'Configuration.[State, LastUpdateStatus]'" wait_state(){ echo "Waiting on function state update..." From 07aa1998bde9891ffb3261ac1de6a64af000ab52 Mon Sep 17 00:00:00 2001 From: an-nihil00 <32604310+an-nihil00@users.noreply.github.com> Date: Tue, 15 Mar 2022 08:08:17 -0500 Subject: [PATCH 04/10] so many errors aaaaa --- entrypoint.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index e27d485..f37788b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -poll_command="aws lambda get-function --function-name \"${INPUT_LAMBDA_FUNCTION_NAME}\" --query 'Configuration.[State, LastUpdateStatus]'" +poll_command="aws lambda get-function --function-name \"${INPUT_LAMBDA_FUNCTION_NAME}\" --query \"Configuration.[State, LastUpdateStatus]\"" wait_state(){ echo "Waiting on function state update..." @@ -9,6 +9,10 @@ wait_state(){ do sleep 1 done + until ${poll_command} | grep "Successful" + do + sleep 1 + done } install_zip_dependencies(){ From 47ffca4817518b59fc7ac19b4de6439bbe32ada2 Mon Sep 17 00:00:00 2001 From: an-nihil00 <32604310+an-nihil00@users.noreply.github.com> Date: Tue, 15 Mar 2022 08:13:31 -0500 Subject: [PATCH 05/10] limited what files to deploy, and hopefully fixed polling? --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index f37788b..75c9063 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -poll_command="aws lambda get-function --function-name \"${INPUT_LAMBDA_FUNCTION_NAME}\" --query \"Configuration.[State, LastUpdateStatus]\"" +poll_command="aws lambda get-function --function-name \"${INPUT_LAMBDA_FUNCTION_NAME}\" --query Configuration.[State,LastUpdateStatus]" wait_state(){ echo "Waiting on function state update..." @@ -32,7 +32,7 @@ publish_dependencies_as_layer(){ publish_function_code(){ echo "Deploying the code itself..." - zip -r code.zip . -x \*.git\* + zip -r code.zip *.py -x \*.git\* aws lambda update-function-code --function-name "${INPUT_LAMBDA_FUNCTION_NAME}" --zip-file fileb://code.zip } From dbace7883066866c005f9fa26eebf9b02a488fa2 Mon Sep 17 00:00:00 2001 From: an-nihil00 <32604310+an-nihil00@users.noreply.github.com> Date: Tue, 15 Mar 2022 08:17:04 -0500 Subject: [PATCH 06/10] ugh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 75c9063..b3af887 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -poll_command="aws lambda get-function --function-name \"${INPUT_LAMBDA_FUNCTION_NAME}\" --query Configuration.[State,LastUpdateStatus]" +poll_command="aws lambda get-function --function-name ${INPUT_LAMBDA_FUNCTION_NAME} --query Configuration.[State,LastUpdateStatus]" wait_state(){ echo "Waiting on function state update..." From ed999781cad2add8153cad02498fa7f716d81de1 Mon Sep 17 00:00:00 2001 From: Josh Rosenberg Date: Fri, 1 Jan 2021 14:27:06 -0500 Subject: [PATCH 07/10] add option to upload dependency layer to S3 first --- README.md | 4 ++++ action.yml | 8 ++++++++ entrypoint.sh | 15 ++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1cad90c..7f40666 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,10 @@ Stored as secrets or env vars, doesn't matter. But also please don't put your AW - Partial ARN - `123456789012:function:my-function` - `requirements_txt` The name/path for the `requirements.txt` file. Defaults to `requirements.txt`. +- `use_s3` + Whether to upload the dependency layer zip to S3 (required if the zip exceeds 50MB) or not. (If not, it's uploaded directly to Lambda.) Defaults to `false`. +- `s3_bucket_name` + The S3 bucket name used if you are uploading the dependency layer to S3. ### Example workflow diff --git a/action.yml b/action.yml index f06de98..45af266 100644 --- a/action.yml +++ b/action.yml @@ -12,6 +12,14 @@ inputs: lambda_function_name: description: The Lambda function name. Check the AWS docs/readme for examples. required: true + use_s3: + description: Whether to use S3 (true) or not (false) for the dependencies layer upload. + required: false + default: 'false' + s3_bucket_name: + description: The S3 bucket name for the dependencies layer upload. + required: false + default: no-bucket-name-here runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index b3af887..3c84e38 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -23,9 +23,18 @@ 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) - LAYER_VERSION=$(jq '.Version' <<< "$result") + if [ "$INPUT_USE_S3" = true ] + then + echo "Uploading dependencies to S3..." + aws s3 cp dependencies.zip s3://"${INPUT_S3_BUCKET_NAME}"/dependencies.zip + echo "Publishing dependencies from S3 as a layer..." + local result=$(aws lambda publish-layer-version --layer-name "${INPUT_LAMBDA_LAYER_ARN}" --content S3Bucket="${INPUT_S3_BUCKET_NAME}",S3Key=dependencies.zip) + LAYER_VERSION=$(jq '.Version' <<< "$result") + else + echo "Publishing dependencies as a layer..." + local result=$(aws lambda publish-layer-version --layer-name "${INPUT_LAMBDA_LAYER_ARN}" --zip-file fileb://dependencies.zip) + LAYER_VERSION=$(jq '.Version' <<< "$result") + fi rm -rf python rm dependencies.zip } From e4aadf0b4f1715951bf88f3f912ae817c78c142d Mon Sep 17 00:00:00 2001 From: Josh Rosenberg Date: Mon, 4 Jan 2021 13:12:48 -0500 Subject: [PATCH 08/10] a little more compact --- entrypoint.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 3c84e38..3532894 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -29,12 +29,11 @@ publish_dependencies_as_layer(){ aws s3 cp dependencies.zip s3://"${INPUT_S3_BUCKET_NAME}"/dependencies.zip echo "Publishing dependencies from S3 as a layer..." local result=$(aws lambda publish-layer-version --layer-name "${INPUT_LAMBDA_LAYER_ARN}" --content S3Bucket="${INPUT_S3_BUCKET_NAME}",S3Key=dependencies.zip) - LAYER_VERSION=$(jq '.Version' <<< "$result") else echo "Publishing dependencies as a layer..." local result=$(aws lambda publish-layer-version --layer-name "${INPUT_LAMBDA_LAYER_ARN}" --zip-file fileb://dependencies.zip) - LAYER_VERSION=$(jq '.Version' <<< "$result") fi + LAYER_VERSION=$(jq '.Version' <<< "$result") rm -rf python rm dependencies.zip } From 0617bdbca0047204b57c446f7f8deed23e6e58c8 Mon Sep 17 00:00:00 2001 From: rosenbergj Date: Wed, 13 Apr 2022 11:39:34 -0400 Subject: [PATCH 09/10] update to python 3.9 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 869eedd..feb009d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.6 +FROM python:3.9 RUN apt-get update RUN apt-get install -y jq zip From e194450fba0fbcf1f6146f1ef55f9965a211dd85 Mon Sep 17 00:00:00 2001 From: rosenbergj Date: Mon, 15 Sep 2025 10:38:28 -0400 Subject: [PATCH 10/10] Update to python 3.13 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index feb009d..fbd9c15 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9 +FROM python:3.13 RUN apt-get update RUN apt-get install -y jq zip