-
-
Notifications
You must be signed in to change notification settings - Fork 171
Expand file tree
/
Copy pathdestroy-workspace.sh
More file actions
executable file
·42 lines (34 loc) · 1.2 KB
/
Copy pathdestroy-workspace.sh
File metadata and controls
executable file
·42 lines (34 loc) · 1.2 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
#!/bin/bash
# shellcheck source=../actions.sh
source /usr/local/actions.sh
debug
setup
init-backend-workspace
set-plan-args
exec 3>&1
destroy
if [[ $DESTROY_EXIT -eq 1 ]]; then
if grep -q "Run variables are currently not supported" "$STEP_TMP_DIR/terraform_destroy.stderr"; then
set-remote-plan-args
destroy
fi
fi
if [[ $DESTROY_EXIT -eq 1 ]]; then
cat >&2 "$STEP_TMP_DIR/terraform_destroy.stderr"
if lock-info "$STEP_TMP_DIR/terraform_destroy.stderr"; then
set_output failure-reason state-locked
else
set_output failure-reason destroy-failed
fi
exit 1
fi
if [[ "$TERRAFORM_BACKEND_TYPE" == "remote" || "$TERRAFORM_BACKEND_TYPE" == "cloud" ]]; then
terraform-cloud-workspace delete "$INPUT_WORKSPACE"
else
# We can't delete an active workspace, so re-initialize with a 'default' workspace (which may not exist)
init-backend-default-workspace
# shellcheck disable=SC2086
debug_log $TOOL_COMMAND_NAME workspace delete $VARIABLE_ARGS -no-color -lock-timeout=300s "$INPUT_WORKSPACE"
# shellcheck disable=SC2086
(cd "$INPUT_PATH" && $TOOL_COMMAND_NAME workspace delete $VARIABLE_ARGS -no-color -lock-timeout=300s "$INPUT_WORKSPACE")
fi