feat(toolkit-lib): surface resource delete failures in DeployResult#1576
Merged
Conversation
When CloudFormation updates a stack and a resource fails to delete (e.g. a non-empty S3 bucket being replaced), it retries 3 times, then abandons the deletion and marks the update as successful (See the [CloudFormation documentation][1]). The resource is removed from the stack's scope but still exists and may incur charges. Until now, this condition was invisible to programmatic consumers of `toolkit-lib` and to integration tests. Changes: - Adds `deleteFailures: ResourceDeleteFailure[]` to `DeployedStack` (public API), exposing resources that CloudFormation failed to delete during a stack update but silently skipped. - Tracks `DELETE_FAILED` events in `StackEventPoller` during the deployment monitoring phase, and threads them through the internal `SuccessfulDeployStackResult` to the public `DeployResult`. - In `integ-runner`, the "actual" deploy (the stack update) now checks for delete failures and fails the test by default, making it impossible for integration tests to silently pass when resources leak. - Adds per-test-case `allowDeleteFailures` option in the integ test manifest (`TestOptions`) and a global `--allow-delete-failures` CLI flag as a fallback for cases where this behavior is expected. [1]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/troubleshooting.html#troubleshooting-errors-resource-removed-not-deleted
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1576 +/- ##
=======================================
Coverage 88.18% 88.18%
=======================================
Files 76 76
Lines 10841 10841
Branches 1493 1493
=======================================
Hits 9560 9560
Misses 1253 1253
Partials 28 28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
rix0rrr
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When CloudFormation updates a stack and a resource fails to delete (e.g. a non-empty S3 bucket being replaced), it retries 3 times, then abandons the deletion and marks the update as successful (See the CloudFormation documentation). The resource is removed from the stack's scope but still exists and may incur charges. Until now, this condition was invisible to programmatic consumers of
toolkit-liband to integration tests.Changes
deleteFailures: ResourceDeleteFailure[]toDeployedStack(public API), exposing resources that CloudFormation failed to delete during a stack update but silently skipped.DELETE_FAILEDevents inStackEventPollerduring the deployment monitoring phase, and threads them through the internalSuccessfulDeployStackResultto the publicDeployResult.integ-runner, the "actual" deploy (the stack update) now checks for delete failures and fails the test by default, making it impossible for integration tests to silently pass when resources leak.allowDeleteFailuresoption in the integ test manifest (TestOptions) and a global--allow-delete-failuresCLI flag as a fallback for cases where this behavior is expected.Screenshots
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license