Skip to content

feat(toolkit-lib): surface resource delete failures in DeployResult#1576

Merged
aws-cdk-automation merged 1 commit into
mainfrom
otaviom/surface-delete-failures
Jun 1, 2026
Merged

feat(toolkit-lib): surface resource delete failures in DeployResult#1576
aws-cdk-automation merged 1 commit into
mainfrom
otaviom/surface-delete-failures

Conversation

@otaviomacedo
Copy link
Copy Markdown
Contributor

@otaviomacedo otaviomacedo commented Jun 1, 2026

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-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.

Screenshots

Screenshot 2026-06-01 at 10 58 23

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

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
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions github-actions Bot added the p2 label Jun 1, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.18%. Comparing base (6800788) to head (1405a60).

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           
Flag Coverage Δ
suite.unit 88.18% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue Jun 1, 2026
Merged via the queue into main with commit a65d995 Jun 1, 2026
51 checks passed
@aws-cdk-automation aws-cdk-automation deleted the otaviom/surface-delete-failures branch June 1, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants