This repository was archived by the owner on Jan 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathentrypoint.sh
More file actions
44 lines (37 loc) · 1.37 KB
/
entrypoint.sh
File metadata and controls
44 lines (37 loc) · 1.37 KB
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
39
40
41
42
43
44
#!/bin/bash
configure_aws_credentials(){
aws configure set aws_access_key_id "${INPUT_AWS_ACCESS_KEY_ID}"
aws configure set aws_secret_access_key "${INPUT_AWS_SECRET_ACCESS_KEY}"
aws configure set default.region "${INPUT_LAMBDA_REGION}"
}
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(){
configure_aws_credentials
install_zip_dependencies
publish_dependencies_as_layer
publish_function_code
update_function_layers
}
deploy_lambda_function
echo "Each step completed, check the logs if any error occured."