Skip to content

Commit 19ec594

Browse files
dcabibclaude
andcommitted
fix: Address PR aws#8299 code review feedback
Implement all 6 corrections requested by @bnusunny: Must Fix: 1. Fix duplicate nested stack headers by using is_parent parameter to control header display only at top level 2. Support all AWS partitions (aws, aws-cn, aws-us-gov, aws-iso, aws-iso-b) in ARN parsing for nested changeset errors 3. Change return type from Union[Dict[str, List], bool] to Optional[Dict[str, List]] for consistency Should Fix: 4. Add full recursion support for deeply nested stacks (3+ levels) with proper header display for each level 5. Implement pagination using boto3 paginators for large changesets to handle nested stacks with many resources Consider: 6. Add CLI opt-out flag --include-nested-stacks/--no-include-nested-stacks (default: True) to allow users to disable nested stack display for large hierarchies All changes include corresponding unit test updates. Integration tests added to verify nested stack changeset display functionality. Related: aws#2406 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3cea2fe commit 19ec594

14 files changed

Lines changed: 495 additions & 67 deletions

File tree

samcli/commands/deploy/command.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@
108108
is_flag=True,
109109
help="Prompt to confirm if the computed changeset is to be deployed by SAM CLI.",
110110
)
111+
@click.option(
112+
"--include-nested-stacks/--no-include-nested-stacks",
113+
default=True,
114+
required=False,
115+
is_flag=True,
116+
help="Display changes for nested stacks in the changeset. "
117+
"For large nested stack hierarchies, use --no-include-nested-stacks to reduce output verbosity. "
118+
"Defaults to displaying nested stack changes.",
119+
)
111120
@click.option(
112121
"--disable-rollback/--no-disable-rollback",
113122
default=False,
@@ -191,6 +200,7 @@ def cli(
191200
metadata,
192201
guided,
193202
confirm_changeset,
203+
include_nested_stacks,
194204
signing_profiles,
195205
resolve_s3,
196206
resolve_image_repos,
@@ -226,6 +236,7 @@ def cli(
226236
metadata,
227237
guided,
228238
confirm_changeset,
239+
include_nested_stacks,
229240
ctx.region,
230241
ctx.profile,
231242
signing_profiles,
@@ -260,16 +271,17 @@ def do_cli(
260271
metadata,
261272
guided,
262273
confirm_changeset,
263-
region,
264-
profile,
265-
signing_profiles,
266-
resolve_s3,
267-
config_file,
268-
config_env,
269-
resolve_image_repos,
270-
disable_rollback,
271-
on_failure,
272-
max_wait_duration,
274+
include_nested_stacks=True,
275+
region=None,
276+
profile=None,
277+
signing_profiles=None,
278+
resolve_s3=False,
279+
config_file=None,
280+
config_env=None,
281+
resolve_image_repos=False,
282+
disable_rollback=False,
283+
on_failure=None,
284+
max_wait_duration=60,
273285
):
274286
"""
275287
Implementation of the ``cli`` method
@@ -370,6 +382,7 @@ def do_cli(
370382
region=guided_context.guided_region if guided else region,
371383
profile=profile,
372384
confirm_changeset=guided_context.confirm_changeset if guided else confirm_changeset,
385+
include_nested_stacks=include_nested_stacks,
373386
signing_profiles=guided_context.signing_profiles if guided else signing_profiles,
374387
use_changeset=True,
375388
disable_rollback=guided_context.disable_rollback if guided else disable_rollback,

samcli/commands/deploy/core/options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"no_execute_changeset",
3535
"fail_on_empty_changeset",
3636
"confirm_changeset",
37+
"include_nested_stacks",
3738
"disable_rollback",
3839
"on_failure",
3940
"force_upload",

samcli/commands/deploy/deploy_context.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ def __init__(
6969
region,
7070
profile,
7171
confirm_changeset,
72-
signing_profiles,
73-
use_changeset,
74-
disable_rollback,
75-
poll_delay,
76-
on_failure,
77-
max_wait_duration,
72+
include_nested_stacks=True,
73+
signing_profiles=None,
74+
use_changeset=True,
75+
disable_rollback=False,
76+
poll_delay=0.5,
77+
on_failure=None,
78+
max_wait_duration=60,
7879
):
7980
self.template_file = template_file
8081
self.stack_name = stack_name
@@ -101,6 +102,7 @@ def __init__(
101102
self.s3_uploader = None
102103
self.deployer = None
103104
self.confirm_changeset = confirm_changeset
105+
self.include_nested_stacks = include_nested_stacks
104106
self.signing_profiles = signing_profiles
105107
self.use_changeset = use_changeset
106108
self.disable_rollback = disable_rollback
@@ -257,6 +259,7 @@ def deploy(
257259
notification_arns=notification_arns,
258260
s3_uploader=s3_uploader,
259261
tags=tags,
262+
include_nested_stacks=self.include_nested_stacks,
260263
)
261264
click.echo(self.MSG_SHOWCASE_CHANGESET.format(changeset_id=result["Id"]))
262265

samcli/commands/deploy/guided_context.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ def run(self):
584584
region=self.guided_region,
585585
profile=self.guided_profile,
586586
confirm_changeset=self.confirm_changeset,
587+
include_nested_stacks=True,
587588
capabilities=self._capabilities,
588589
signing_profiles=self.signing_profiles,
589590
disable_rollback=self.disable_rollback,

samcli/commands/sync/command.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ def do_cli(
394394
no_execute_changeset=True,
395395
fail_on_empty_changeset=True,
396396
confirm_changeset=False,
397+
include_nested_stacks=True,
397398
use_changeset=False,
398399
force_upload=True,
399400
signing_profiles=None,

0 commit comments

Comments
 (0)