Skip to content

Commit 635936a

Browse files
geroplona-agent
andauthored
Fix preview env GC not deleting terraform workspaces (#21261)
When terraform plan -destroy returns exit code 0 (no changes because resources were already deleted), the script exited before deleting the terraform workspace. This caused the same preview environments to appear in subsequent GC runs. Co-authored-by: Ona <no-reply@ona.com>
1 parent 62e5e2c commit 635936a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

dev/preview/workflow/preview/deploy-preview.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ terraform_plan || PLAN_EXIT_CODE=$?
3939
case ${PLAN_EXIT_CODE} in
4040
0)
4141
log_success "No changes to the plan"
42-
exit 0
42+
# Don't exit yet if DESTROY is set - we still need to delete the workspace
43+
if [ -z "${DESTROY-}" ]; then
44+
exit 0
45+
fi
4346
;;
4447
1)
4548
log_error "Terraform plan failed"

0 commit comments

Comments
 (0)