-
Notifications
You must be signed in to change notification settings - Fork 16
/
invoke_flywaylambda.sh
executable file
·50 lines (44 loc) · 1.16 KB
/
invoke_flywaylambda.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
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
invoke_lambda() {
aws lambda invoke \
--invocation-type RequestResponse \
--function-name 'flyway-awslambda-dbmigration' \
--region ${REGION} \
--payload "{\"bucket_name\":\"${BUCKET}\", \"prefix\":\"${PREFIX}\", \"flyway_conf\":\"${CONF}\"}" \
migration_result.json
cat migration_result.json
echo ""
}
show_usage() {
echo "Invoke Flyway AWS Lambda function."
echo "Usage..."
echo "./invoke_flywaylambda.sh -r REGION -b BUCKET_NAME -p PREFIX [-c FLYWAY_CONF] [-h]"
echo " -r : AWS Region for Flyway Lambda function."
echo " -b : Bucket name Flyway resources deployed."
echo " -p : Prefix name Flyway resources deployed."
echo " -c : Flyway configuration file name.(Optional. Default 'flyway.conf')"
echo " -h : Show help."
exit 1
}
while getopts r:b:p:c:h OPT
do
case $OPT in
r) REGION=$OPTARG
;;
b) BUCKET=$OPTARG
;;
p) PREFIX=$OPTARG
;;
c) CONF=$OPTARG
;;
h) show_usage
;;
\?) show_usage
;;
esac
done
[ "${REGION}" == "" ] && show_usage
[ "${BUCKET}" == "" ] && show_usage
[ "${PREFIX}" == "" ] && show_usage
[ "${CONF}" == "" ] && CONF="flyway.conf"
invoke_lambda