Skip to content
This repository was archived by the owner on Jul 20, 2024. It is now read-only.

Commit e12fd92

Browse files
author
Pete Dunlap
committed
adds customizable predeploy script for layers
1 parent bdad983 commit e12fd92

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ This example workflow assumes your `requirements.txt` is in the root directory a
1717

1818
The below workflow would publish code to layers (pip and any custom layers) and functions (first_function and second_function), and finally also attach the layers to those updated functions.
1919

20+
For any custom layers, before the files are copied and zipped and uploaded to AWS, any custom script can be executed if it is placed inside the layer folder and named `predeploy.sh`
21+
2022

2123
### Environment variables
2224
Storing credentials as a Github secret is strongly recommended.

entrypoint.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ publish_custom_layers(){
2727
else
2828
echo "Publishing custom layer 1"
2929
mkdir python
30+
INIT_FILE=$INPUT_CUSTOM_LAYER_1_PATH/predeploy.sh
31+
if [ -f "$INIT_FILE" ]; then
32+
echo "$INIT_FILE exists."
33+
cd $INPUT_CUSTOM_LAYER_1_PATH
34+
./predeploy.sh
35+
cd ..
36+
fi
3037
cp -r ${INPUT_CUSTOM_LAYER_1_PATH} python
3138
zip -r custom_layer_1.zip ./python
3239
local result=$(aws lambda publish-layer-version --layer-name "${INPUT_CUSTOM_LAYER_1_ARN}" --zip-file fileb://custom_layer_1.zip)
@@ -41,6 +48,13 @@ publish_custom_layers(){
4148
else
4249
echo "Publishing custom layer 2"
4350
mkdir python
51+
INIT_FILE=$INPUT_CUSTOM_LAYER_2_PATH/predeploy.sh
52+
if [ -f "$INIT_FILE" ]; then
53+
echo "$INIT_FILE exists."
54+
cd $INPUT_CUSTOM_LAYER_2_PATH
55+
./predeploy.sh
56+
cd ..
57+
fi
4458
cp -r ${INPUT_CUSTOM_LAYER_2_PATH} python
4559
zip -r custom_layer_2.zip ./python
4660
local result=$(aws lambda publish-layer-version --layer-name "${INPUT_CUSTOM_LAYER_2_ARN}" --zip-file fileb://custom_layer_2.zip)
@@ -55,6 +69,13 @@ publish_custom_layers(){
5569
else
5670
echo "Publishing custom layer 3"
5771
mkdir python
72+
INIT_FILE=$INPUT_CUSTOM_LAYER_3_PATH/predeploy.sh
73+
if [ -f "$INIT_FILE" ]; then
74+
echo "$INIT_FILE exists."
75+
cd $INPUT_CUSTOM_LAYER_3_PATH
76+
./predeploy.sh
77+
cd ..
78+
fi
5879
cp -r ${INPUT_CUSTOM_LAYER_3_PATH} python
5980
zip -r custom_layer_3.zip ./python
6081
local result=$(aws lambda publish-layer-version --layer-name "${INPUT_CUSTOM_LAYER_3_ARN}" --zip-file fileb://custom_layer_3.zip)
@@ -69,6 +90,13 @@ publish_custom_layers(){
6990
else
7091
echo "Publishing custom layer 4"
7192
mkdir python
93+
INIT_FILE=$INPUT_CUSTOM_LAYER_4_PATH/predeploy.sh
94+
if [ -f "$INIT_FILE" ]; then
95+
echo "$INIT_FILE exists."
96+
cd $INPUT_CUSTOM_LAYER_4_PATH
97+
./predeploy.sh
98+
cd ..
99+
fi
72100
cp -r ${INPUT_CUSTOM_LAYER_4_PATH} python
73101
zip -r custom_layer_4.zip ./python
74102
local result=$(aws lambda publish-layer-version --layer-name "${INPUT_CUSTOM_LAYER_4_ARN}" --zip-file fileb://custom_layer_4.zip)

0 commit comments

Comments
 (0)