-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake
executable file
·93 lines (73 loc) · 1.83 KB
/
make
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash -e
#-----------------------------
#terraform bootstraper util
bootstrap() {
terraform get
}
#-----------------------------
#terraform updater util
update() {
terraform refresh
terraform apply
}
#-----------------------------
#Continius Integration
ci() {
if [ $1 == "tf" ]; then
for m in `ls -1 */*.tf | xargs -I % dirname %`; do (terraform validate "$m" && echo "√ $m") || exit 1 ; done
(terraform validate . && echo "√ .") || exit 1
else
echo "Need indicate specific test"
exit 1
fi
}
#-----------------------------
#garbage collector
gc() {
for file in `find lambda -mindepth 1 -name '*.zip'`; do rm $file; done
#TODO: check why the next line generate etc folder in process for download dependencies
for file in `find lambda -mindepth 1 -maxdepth 1 -type d`; do npm --prefix $file install $file; done
for file in `find lambda -mindepth 1 -maxdepth 1 -type d`; do zip -r ./$file/handler.zip "$file" \
--exclude=**.tf* --exclude=*package.json* --exclude=*package-lock.json* --exclude=*.gitignore* --exclude=*etc*; done
}
#-----------------------------
#lambda generator
new() {
cd ./lambda/
if [ -d "$1" ]; then
echo "Directory already exist, please asign other name to new directory for lambda function"
exit 1
else
mkdir -pv $1
cd $1
npm init -y
touch index.js
echo "module.exports.handler = function (evt, ctx, cbc) {};" > index.js
echo "Create successful, begin play with lambda"
exit 1
fi
}
#-----------------------------
#case switch for options
case "$1" in
gc)
gc
;;
ci)
ci $2
;;
update)
update
;;
bootstrap)
bootstrap
;;
new)
new $2
;;
*)
echo "new | gc | ci | bootstrap"
exit 1
esac
exit 0
#-----------------------------