Skip to content

[FIX] Use the CloudFormation waiter for --prev-stack deletion - #629

Merged
noel-improv merged 1 commit into
awslabs:mainfrom
Anshuman-Prakash:fix/prev-stack-delete-wait
Oct 22, 2026
Merged

noel-improv merged 1 commit into
awslabs:mainfrom
Anshuman-Prakash:fix/prev-stack-delete-wait

Conversation

@Anshuman-Prakash

Copy link
Copy Markdown
Contributor

Description

build-tests.sh --prev-stack <name> never got past the deletion wait. The loop polled describe-stacks until it saw DELETE_COMPLETE, but describe-stacks fails once the stack is gone, so the status came back empty and the loop kept going. It also kept going on DELETE_FAILED. This replaces the loop with aws cloudformation wait stack-delete-complete, which finishes once the stack is deleted, fails on DELETE_FAILED, and has its own timeout.

Changes

  • Replace the describe-stacks polling loop with aws cloudformation wait stack-delete-complete --stack-name "$PREV_STACK_NAME" --region "$REGION_NAME". If the waiter fails, print an ERROR: line and exit 1 so the script doesn't go on to create-stack.
  • Move the misplaced closing quote on the PREV_STACK_NAME echo line so it matches the lines around it.

Problem

Related issue (if any): Fixes #622

Testing

  • Unit tests added/updated

  • Integration tests added (as appropriate)

  • Existing tests pass (pytest)

  • Tested manually (describe below)

  • bash -n integration-tests/build-tests.sh passes.

  • shellcheck (koalaman/shellcheck:stable) on the old and new script: the notes on the changed lines (SC2086 on the two describe-stacks calls, SC2291/SC2086 on the echo line) are gone, and no new findings appear. The total goes from 32 to 28. The remaining SC2086 on the existing delete-stack line is left alone.

  • I haven't run this against a live stack.

Checklist

  • Code follows existing style and conventions
  • License headers present on new files
  • Documentation updated (if applicable)
  • No breaking changes (or clearly documented)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

🤖 Generated with Claude Code

The hand-rolled loop polled describe-stacks until it saw DELETE_COMPLETE,
but describe-stacks fails once the stack is gone, so the status became
empty and the loop never exited. It also spun forever on DELETE_FAILED.
Use `aws cloudformation wait stack-delete-complete`, which handles a
deleted stack, fails on DELETE_FAILED and has its own timeout, and exit
with an error if it fails.

Also fix the misplaced closing quote on the PREV_STACK_NAME echo line.

Fixes awslabs#622

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@noel-improv noel-improv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracking this down. The diagnosis in #622 holds and the fix is right. I ran this against a live stack as well as the new block and all passed.

The echo quote fix is correct too. Nothing to change from my side. Approving!

@noel-improv
noel-improv merged commit 646cfb6 into awslabs:main Oct 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] build-tests.sh --prev-stack wait loop never exits

3 participants