-
Notifications
You must be signed in to change notification settings - Fork 38
/
manage-stack
executable file
·84 lines (74 loc) · 1.5 KB
/
manage-stack
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
#!/usr/bin/env bash
#set -x
PARAMS=""
while (( "$#" )); do
case "$1" in
-u|--update)
UPDATE=1
shift 1
;;
-s|--stack-name)
STACK_NAME_ARG=$2
shift 2
;;
-t|--template)
TEMPLATE_ARG=$2
shift 2
;;
-p|--profile)
PROFILE_ARG=$2
shift 2
;;
-r|--region)
REGION_ARG=$2
shift 2
;;
--)
shift
break
;;
-*|--*=)
echo "Error: Unsupported flag $1" >&2
exit 1
;;
*)
PARAMS="$PARAMS $1"
shift
;;
esac
done
eval set -- "$PARAMS"
if [ -z $UPDATE ]; then
CMD='create-stack --enable-termination-protection'
else
CMD='update-stack'
fi
if [ -z ${STACK_NAME_ARG+x} ]; then
echo 'You must supply -s|--stack-name'
exit 1
else
STACK_NAME=$STACK_NAME_ARG
fi
if [ -z ${TEMPLATE_ARG+x} ]; then
TEMPLATE=vpn-gateway-strongswan.yml
else
TEMPLATE=$TEMPLATE_ARG
fi
if [ -z ${PROFILE_ARG+x} ]; then
PROFILE=
else
PROFILE="--profile $PROFILE_ARG"
fi
if [ -z ${REGION_ARG+x} ]; then
REGION=
else
REGION="--region $REGION_ARG"
fi
aws cloudformation ${CMD} \
--stack-name ${STACK_NAME} \
--template-body file://./${TEMPLATE} \
--parameters file://${1} \
--capabilities CAPABILITY_NAMED_IAM \
${REGION} \
${PROFILE}
#aws cloudformation wait stack-create-complete --stack-name ${STACK_NAME} --region ${AWS_REGION} --profile ${AWS_PROFILE}