Skip to content

feat(cli): add --concurrency flag to cdk destroy#1221

Merged
mrgrain merged 2 commits intoaws:mainfrom
mikevoets:feat/destroy-concurrency
Mar 13, 2026
Merged

feat(cli): add --concurrency flag to cdk destroy#1221
mrgrain merged 2 commits intoaws:mainfrom
mikevoets:feat/destroy-concurrency

Conversation

@mikevoets
Copy link
Contributor

@mikevoets mikevoets commented Mar 13, 2026

Fixes #752

Description

Add --concurrency flag to cdk destroy, mirroring the existing cdk deploy --concurrency behavior. When set to a value greater than 1, multiple stacks are destroyed in parallel while respecting dependency order (reversed from deploy).

Uses WorkGraph with reversed dependency edges to orchestrate parallel destruction. A new WorkGraph.processStacks() method provides a stack-only execution path, and the graph construction logic lives in its own build-destroy-work-graph module.

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

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

@github-actions github-actions bot added the p2 label Mar 13, 2026
@aws-cdk-automation aws-cdk-automation requested a review from a team March 13, 2026 06:22
@github-actions github-actions bot added effort/medium 1-3 days of effort feature-request p1 and removed p2 labels Mar 13, 2026
@mikevoets mikevoets marked this pull request as ready for review March 13, 2026 08:08
Copy link
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

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

Nice one!

@codecov-commenter
Copy link

codecov-commenter commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.05%. Comparing base (cf3cd7d) to head (25be8f0).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
packages/aws-cdk/lib/cli/cdk-toolkit.ts 95.45% 1 Missing ⚠️
packages/aws-cdk/lib/cli/cli.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1221      +/-   ##
==========================================
+ Coverage   87.79%   88.05%   +0.25%     
==========================================
  Files          73       73              
  Lines       10168    10187      +19     
  Branches     1343     1351       +8     
==========================================
+ Hits         8927     8970      +43     
+ Misses       1217     1193      -24     
  Partials       24       24              
Flag Coverage Δ
suite.unit 88.05% <91.66%> (+0.25%) ⬆️

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.

@mrgrain mrgrain added this pull request to the merge queue Mar 13, 2026
Merged via the queue into aws:main with commit 403fe8e Mar 13, 2026
41 checks passed
@mikevoets mikevoets deleted the feat/destroy-concurrency branch March 13, 2026 12:57
mrgrain added a commit to awsdocs/aws-cdk-guide that referenced this pull request Mar 24, 2026
## Description

**Documentation Change Type:**

- [ ] Typo/grammar fix
- [ ] Clarification or minor improvement
- [ ] New example or code snippet
- [x] New section or topic
- [ ] Major restructuring or enhancement

**Affected Documentation Page(s):**
- https://docs.aws.amazon.com/cdk/v2/guide/ref-cli-cmd-destroy.html

## Description of Changes

Adds the new `--concurrency <NUMBER>` option to the `cdk destroy`
command reference page. This option was introduced in
[aws/aws-cdk-cli#1221](aws/aws-cdk-cli#1221).
Also adds a usage example showing concurrent stack deletion.

## Motivation and Context

The `--concurrency` flag for `cdk destroy` has shipped in the CDK CLI
but is not yet documented. The option mirrors the existing `cdk deploy
--concurrency` behavior, allowing users to destroy multiple stacks in
parallel while respecting dependency order.

## How Has This Been Validated?

- Verified formatting is consistent with the existing `--concurrency`
option on the `cdk deploy` reference page
- Confirmed all facts against the source PR
([aws/aws-cdk-cli#1221](aws/aws-cdk-cli#1221))

## Checklist

- [x] My changes follow the [AsciiDoc
syntax](./CONTRIBUTING.md#asciidoc-syntax-reference) guidelines
- [x] I have previewed my changes using GitHub's preview or a local
AsciiDoc renderer
- [x] My changes maintain consistent formatting with the rest of the
documentation
- [x] I have checked that all links work correctly

## Additional Information

The option entry and example were modeled directly on the existing
`--concurrency` documentation for `cdk deploy` to ensure consistency.

---------

Co-authored-by: Momo Kornher <mail@moritzkornher.de>
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.

cli: cdk destroy with concurrency

3 participants