File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,9 +108,15 @@ cleanup_orphan() {
108108# previous recovery stacks (all-demo-recovery-*).
109109sweep_orphan_stacks () {
110110 local orphans orphan
111+ # CRITICAL: filter on ParentId being absent. Stacks whose name starts
112+ # with ${STACK}- but ParentId is set are LIVE nested children of the
113+ # active umbrella, not orphans. Without this filter the sweep happily
114+ # deletes the working umbrella's children when called from a healthy
115+ # CREATE_COMPLETE state (which it is — use_canonical runs sweep before
116+ # checking whether the umbrella is alive).
111117 orphans=$( aws cloudformation list-stacks \
112118 --stack-status-filter CREATE_COMPLETE UPDATE_COMPLETE UPDATE_ROLLBACK_COMPLETE DELETE_FAILED UPDATE_ROLLBACK_FAILED CREATE_FAILED UPDATE_FAILED ROLLBACK_COMPLETE ROLLBACK_FAILED \
113- --query " StackSummaries[?starts_with(StackName, \` ${STACK} -\` ) ].StackName" \
119+ --query " StackSummaries[?starts_with(StackName, ' ${STACK} -') && ParentId== \` null \` ].StackName" \
114120 --output text 2> /dev/null | tr ' \t' ' \n' | grep -v ' ^$' || true)
115121 [ -z " $orphans " ] && { echo " No orphan ${STACK} -* stacks to sweep." ; return 0; }
116122 echo " Orphan stacks to sweep:"
You can’t perform that action at this time.
0 commit comments