-
Notifications
You must be signed in to change notification settings - Fork 59
/
entrypoint.sh
executable file
·38 lines (32 loc) · 1.06 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
set -e
install_zip_dependencies(){
echo "Installing and zipping dependencies..."
mkdir python
pip install --target=python -r "${INPUT_REQUIREMENTS_TXT}"
zip -r dependencies.zip ./python
}
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")
rm -rf python
rm dependencies.zip
}
publish_function_code(){
echo "Deploying the code itself..."
zip -r code.zip . -x \*.git\*
aws lambda update-function-code --function-name "${INPUT_LAMBDA_FUNCTION_NAME}" --zip-file fileb://code.zip
}
update_function_layers(){
echo "Using the layer in the function..."
aws lambda update-function-configuration --function-name "${INPUT_LAMBDA_FUNCTION_NAME}" --layers "${INPUT_LAMBDA_LAYER_ARN}:${LAYER_VERSION}"
}
deploy_lambda_function(){
install_zip_dependencies
publish_dependencies_as_layer
publish_function_code
update_function_layers
}
deploy_lambda_function
echo "Done."