-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzip-lambdas.sh
More file actions
executable file
·49 lines (43 loc) · 1.08 KB
/
zip-lambdas.sh
File metadata and controls
executable file
·49 lines (43 loc) · 1.08 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
45
46
47
48
49
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
project_root=$(pwd)
log() {
printf "%s %s %s\n" "zip-lambdas INFO" "$(date)" "$1"
}
log "project root = $project_root"
zip_lambda() {
function_name=$1
log "zipping lambda $function_name"
cd $project_root/lambda/$function_name
output=$project_root/deployment/$function_name.zip
log "output file = $output"
if [ -f $output ]; then
log "delete existing $output"
rm $output
fi
log "install requirements"
if [ -f requirements.txt ]; then
log "installing python dependency for lambda $function_name"
virtualenv .env -p python3
pip=.env/bin/pip
$pip install -r requirements.txt -t lib --upgrade
fi
log "zipping $function_name"
rm -rf __pycache__
zip -X -r $output *.py
if [ -d lib ]; then
log "zipping python dependency for lambda $function_name"
cd lib
zip -g -r $output *
fi
log "done zipping $function_name"
}
if [ -d lambda ]; then
cd lambda
for dir in *
do
zip_lambda $dir
done
fi