forked from ruzin/terraform_aws_lambda_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpy_pkg.sh
More file actions
36 lines (34 loc) · 1.05 KB
/
Copy pathpy_pkg.sh
File metadata and controls
36 lines (34 loc) · 1.05 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
#!/bin/bash
#set directory permissions
cd $path_cwd
dir_name=lambda_pkg_$random_string/
mkdir $dir_name
#virtual env setup
cd $path_module
virtualenv -p $runtime env-$function_name
source env-$function_name/bin/activate
#installing python dependencies
FILE=$source_code_path/requirements.txt
if [ -f $FILE ]; then
echo "requirement.txt file exists in source_code_path. Installing dependencies.."
pip install -q -r $FILE --upgrade
else
echo "requirement.txt file does not exist. Skipping installation of dependencies."
fi
#deactivate virtualenv
deactivate
#creating deployment package
cd env-$function_name/lib/$runtime/site-packages/
cp -r . $path_cwd/$dir_name
cp -r $source_code_path/ $path_cwd/$dir_name
#removing virtual env folder
rm -rf $path_module/env-$function_name/
#add lambda_pkg directory to .gitignore
GIT_FILE=$path_cwd/.gitignore
if [ -f $GIT_FILE ]; then
echo '#ignore lambda_pkg dir' >> $path_cwd/.gitignore
echo $dir_name >> $path_cwd/.gitignore
else
echo '#ignore lambda_pkg dir' > $path_cwd/.gitignore
echo $dir_name > $path_cwd/.gitignore
fi