-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathccloud_stack_destroy.sh
More file actions
executable file
·43 lines (35 loc) · 1.39 KB
/
ccloud_stack_destroy.sh
File metadata and controls
executable file
·43 lines (35 loc) · 1.39 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
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
# Source library
source $DIR/../../utils/helper.sh
source $DIR/../../utils/ccloud_library.sh
ccloud::validate_version_cli $CLI_MIN_VERSION || exit 1
ccloud::validate_logged_in_cli || exit 1
check_jq || exit 1
if [ -z "$1" ]; then
echo "ERROR: Must supply argument that is the client configuration file created from './ccloud_stack_create.sh'. (Is it in stack-configs/ folder?) "
exit 1
else
CONFIG_FILE=$1
fi
PRESERVE_ENVIRONMENT="${PRESERVE_ENVIRONMENT:-false}"
if [[ $PRESERVE_ENVIRONMENT == "false" ]]; then
read -p "This script will destroy all the resources (including the Confluent Cloud environment) in $CONFIG_FILE. Do you want to proceed? [y/n] " -n 1 -r
else
read -p "This script will destroy all the resources (except the Confluent Cloud environment) in $CONFIG_FILE. Do you want to proceed? [y/n] " -n 1 -r
fi
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
ccloud::validate_ccloud_config $CONFIG_FILE || exit 1
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
ccloud::generate_configs $CONFIG_FILE > /dev/null
source delta_configs/env.delta
SERVICE_ACCOUNT_ID=$(ccloud::get_service_account $CLOUD_KEY) || exit 1
echo "Retrieved service account id $SERVICE_ACCOUNT_ID"
echo
ccloud::destroy_ccloud_stack $SERVICE_ACCOUNT_ID
echo
echo "Tip: 'confluent' CLI currently has no environment set"