-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteardown.sh
More file actions
executable file
·121 lines (93 loc) · 3.16 KB
/
teardown.sh
File metadata and controls
executable file
·121 lines (93 loc) · 3.16 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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
##############################################################################
##############################################################################
##
## this script reads in an env file that should have the following
## exported environment variables:
##
## STACK_NAME = the name of the stack to be deployed
## REGION = the region to deploy the stack within
##
##############################################################################
##############################################################################
##############################################################################
##############################################################################
##
## MAGIC NUMBERS
##
##############################################################################
##############################################################################
ARG_NUMBER=1
##############################################################################
##############################################################################
##
## USAGE
##
##############################################################################
##############################################################################
usage(){
if [ $# -lt $ARG_NUMBER ]; then
echo "Usage: "
echo "$0 \ "
echo " --env-file [ENV_FILE_PATH] \ "
exit 1
fi
}
##############################################################################
##############################################################################
##
## PARSE ARGS
##
##############################################################################
##############################################################################
parse_args(){
while [[ $# > 1 ]];
do
key="$1"
case $key in
--env-file)
ENV_FILE="$2"
shift # past argument
;;
*)
# unknown option
;;
esac
shift
done
}
##############################################################################
##############################################################################
##
## supporting functions
##
##############################################################################
##############################################################################
delete_stack(){
echo "[-] $(date) - Deleting stack ... $STACK_NAME"
aws cloudformation delete-stack \
--stack-name $STACK_NAME \
--region $REGION
}
wait_stack_delete(){
echo "[-] $(date) - Waiting on stack delete ... $STACK_NAME"
aws cloudformation wait stack-delete-complete \
--stack-name $STACK_NAME \
--region $REGION
}
##############################################################################
##############################################################################
##
## MAIN
##
##############################################################################
##############################################################################
main(){
delete_stack
wait_stack_delete
echo "[+] $(date) - Stack teardown complete"
}
usage $@
parse_args $@
source $ENV_FILE
main