forked from confluentinc/demo-scene
-
Notifications
You must be signed in to change notification settings - Fork 0
/
destroy_demo_environment.sh
executable file
·70 lines (50 loc) · 1.65 KB
/
destroy_demo_environment.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
set -e
PRJ_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
UTILS_DIR="${PRJ_DIR}/utils"
TFS_PATH="${PRJ_DIR}/terraform"
TMP_FOLDER="$PRJ_DIR/tmp"
ENV_FILEPATH="${TMP_FOLDER}/envs.created"
CCLOUD_STACK_PATH="${PRJ_DIR}/ccloud/ccloud_stack"
STACK_FILEPATH="${TMP_FOLDER}/stack.created"
CFG_FILE="${PRJ_DIR}/config/demo.cfg"
function destroy_ccloud_resources (){
# Destroy Confluent Cloud resources
export PRESERVE_ENVIRONMENT=false
#ENVIRONMENT_NAME=$DEMO_NAME
ENVIRONMENT_NAME_PREFIX=$DEMO_NAME
echo "This process will also delete Environment: $DEMO_NAME"
export QUIET=false
cd $CCLOUD_STACK_PATH
# Destroy Confluent Cloud resources
for STACK_FILE in $(ls $CCLOUD_STACK_PATH/stack-configs);
do
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
CONFIG_FILE=$CCLOUD_STACK_PATH/stack-configs/$STACK_FILE
source ./ccloud_stack_destroy.sh $CONFIG_FILE
#rm $CONFIG_FILE
done
#echo "Removing folder: $PRJ_DIR/delta_configs"
#rm -r $PRJ_DIR/delta_configs
}
function destroy_infrastructure (){
cd $WS_REPO_FOLDER
./workshop-destroy.py --dir $TMP_FOLDER
rm $TMP_FOLDER/workshop.yaml
cd $TFS_PATH
terraform destroy --auto-approve
rm -f "${TFS_PATH}/config.auto.tfvars"
}
function end_demo {
# Source library
source $UTILS_DIR/demo_helper.sh
# Source demo-specific configurations
source $CFG_FILE
check_jq || exit 1
destroy_ccloud_resources
get_hybrid_workshop_repo
destroy_infrastructure
#rm -f "${TMP_FOLDER}/cluster_1.client.config"
}
mkdir -p logs
end_demo 2>&1 | tee -a logs/demo_destruction.log