-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathterrafuzz.sh
More file actions
executable file
·68 lines (55 loc) · 1.19 KB
/
terrafuzz.sh
File metadata and controls
executable file
·68 lines (55 loc) · 1.19 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
#!/bin/bash
clear
function upload_code_to_s3 {
cd ..
npm run build
cd terrafuzz
./populate_bucket.sh
}
function destroy {
./empty_bucket.sh
terraform destroy -var-file=variables.tfvars
}
function setup_terraform {
terraform init
terraform get
}
function apply_terraform_changes {
terraform apply -var-file=variables.tfvars
WEBSITE=`terraform output | awk -F"website_endpoint" '{print $2}' | sed 's/^[ \t]*=[ \t]/http:\/\//' | tr -d '[:cntrl:]' | sed 's/\[0m$//'`
echo $WEBSITE > website.txt
}
function greeting {
printf "\n\t\033[1;4;36mIt's Terrafuzz Time\033[0m\n"
}
function goodbye {
printf "\n\033[1;33m...you've been Terrafuzzed\033[0m\n"
}
function open_website {
open $(cat website.txt)
}
function deploy {
upload_code_to_s3
goodbye
open_website
}
case "$1" in
apply)
greeting
setup_terraform
apply_terraform_changes
deploy
;;
deploy)
greeting
deploy
;;
destroy)
greeting
destroy
goodbye
;;
*)
echo $"Usage: $0 {apply|deploy|destroy|}"
exit 1
esac