Skip to content

feat(cli): --no-include-nested-stacks option to create deploy change sets without nested stacks - #2195

Closed
DiegoOrtizS wants to merge 4 commits into
aws:mainfrom
DiegoOrtizS:feat/deploy-no-include-nested-stacks
Closed

DiegoOrtizS wants to merge 4 commits into
aws:mainfrom
DiegoOrtizS:feat/deploy-no-include-nested-stacks

Conversation

@DiegoOrtizS

Copy link
Copy Markdown

Closes #2191

Since #1531 (2.1124.0), cdk deploy creates change sets with IncludeNestedStacks: true. For a large hierarchy (one root stack, ~30 nested stacks, 3,000+ resources), change set creation fails with Limit on the number of resources in a single stack operation exceeded. The workarounds are --method=direct (no change set review) or pinning the CLI below 2.1124.0, which also pins aws-cdk-lib.

This PR adds an opt-out with the pre-#1531 behavior:

  • toolkit-lib: ChangeSetDeployment.includeNestedStacks (default true). When false, IncludeNestedStacks is omitted, as for import and revert-drift change sets.
  • CLI: cdk deploy --no-include-nested-stacks (change-set, prepare-change-set, hotswap fallback), or "includeNestedStacks": false in cdk.json, which cdk watch and the follow-up deploy of cdk import also use. The flag wins over cdk.json.
  • README: documents the cost of opting out: nested stack problems only surface during execution, and nested stacks are reported as changed even when they aren't.

The default is unchanged.

Open question: I haven't confirmed yet that a root-only change set stays under the quota for the affected app. The quota page puts the 2,500 limit on the whole deployment, so if more than 2,500 resources really change, this only moves the failure to execution. I'll test this branch on the affected app and report back.

Design notes

  • Explicit option, not an automatic retry on the quota error: a silent retry changes what the user reviews and depends on where CloudFormation reports the error. If the option helps, the quota error could suggest it in a follow-up.
  • No yargs default, so cdk.json can apply; toolkit-lib applies the default.
  • cdk diff and cdk validate --online are out of scope; cdk diff already falls back to a template diff.
  • No effect with --method=direct or --method=execute-change-set. Documented rather than rejected, because rejectIncompatibleOptions can't tell the flag from cdk.json.

Testing: unit tests in toolkit-lib (CreateChangeSet input) and CLI (flag and cdk.json for deploy, watch, import and hotswap fallback). Generated CLI files regenerated with scripts/user-input-gen.ts. Happy to add an integ test on the with-nested-stack fixture.

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

🤖 Generated with Claude Code

DiegoOrtizS and others added 2 commits December 2, 2026 11:47
…e sets without nested stacks

Since aws#1531, deploy change sets are created with `IncludeNestedStacks: true`.
For a large nested stack hierarchy, change set creation then fails with
"Limit on the number of resources in a single stack operation exceeded".

Add an `includeNestedStacks` option to `ChangeSetDeployment` in toolkit-lib
(default `true`) and expose it on `cdk deploy` as
`--[no-]include-nested-stacks` and as `includeNestedStacks` in `cdk.json`.

Closes aws#2191

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Pass the cdk.json setting to the follow-up deploy of `cdk import`.
- Describe the quota error and the cost of opting out (late nested stack
  errors, nested stacks always reported as changed) in JSDoc, flag help
  and README, and say which commands the option affects.
- Test --hotswap-fallback, cdk watch and cdk import; drop a test that
  repeated the default case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DiegoOrtizS and others added 2 commits December 2, 2026 13:10
… quota error

Testing showed that `--no-include-nested-stacks` does not avoid the
2,500 resources per operation quota: CloudFormation counts the resources
that change in the deployment either way, and without nested change sets
the failure only moves to execution, followed by a rollback. Remove the
option again.

Instead, explain the quota error when it shows up. The error is reported
against the first nested stack that hit it, which reads like a problem
with that stack. Add context saying the quota covers the whole
deployment, counts changed resources, cannot be raised, and that the
change must be split into smaller deployments.

Closes aws#2191

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… sets

Also align the hint with the wording of the CloudFormation quotas page,
which does not say whether the quota can be raised.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch is waiting to be deployed

1 active (outdated) and 1 waiting deployments
integ-approval — 97fed8aa Waiting Dec 2, 2026 by DiegoOrtizS via prepare #7831
automation — 70745d7e Deployed Dec 2, 2026 by DiegoOrtizS via Set AutoQueue on PR #2195 #4070
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

1 participant