Skip to content

feat(core): allow indentation suppression in nested stacks#35122

Merged
mergify[bot] merged 4 commits into
aws:mainfrom
jdebuseamazon:jdebuseamazon/nested-stack-suppress-indentation
Feb 2, 2026
Merged

feat(core): allow indentation suppression in nested stacks#35122
mergify[bot] merged 4 commits into
aws:mainfrom
jdebuseamazon:jdebuseamazon/nested-stack-suppress-indentation

Conversation

@jdebuseamazon
Copy link
Copy Markdown
Contributor

Issue # (if applicable)

Closes #32798

Reason for this change

Stacks can be created with an optional suppressTemplateIndentation parameter to determine whether indentation is suppressed. This may for example be useful to keep stack sizes within AWS CloudFormation quotas. However, indentation suppression is currently not supported for nested stacks.

Description of changes

A new suppressTemplateIndentation parameter, based on the Stack suppressTemplateIndentation was added to NestedStackProps. The new parameter was added to the call to the superclass constructor within the NestedStack constructor:

  constructor(scope: Construct, id: string, props: NestedStackProps = { }) {
    const parentStack = findParentStack(scope);

    super(scope, id, {
      env: { account: parentStack.account, region: parentStack.region },
      synthesizer: new NestedStackSynthesizer(parentStack.synthesizer),
      description: props.description,
      crossRegionReferences: parentStack._crossRegionReferences,
      suppressTemplateIndentation: props.suppressTemplateIndentation,
    });

Description of how you validated changes

Unit tests and an integration test. The integration test was based on the existing integ.nested-stack-references.ts.

Checklist


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

@jdebuseamazon jdebuseamazon requested a review from a team as a code owner July 31, 2025 15:52
@aws-cdk-automation aws-cdk-automation requested a review from a team July 31, 2025 15:52
@github-actions github-actions Bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Jul 31, 2025
@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 9437b00
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jul 31, 2025
@fossamagna
Copy link
Copy Markdown

Why is this PR still sitting here without review?
I wait to merged this PR.

@fossamagna
Copy link
Copy Markdown

Hi @otaviomacedo @kaizencc

I’m sorry to bother you, but I’d like to ask for a review on this PR.

This change addresses the nested stack template size issue discussed in #32798 by allowing
suppressTemplateIndentation to be propagated via NestedStackProps.
This is a blocking issue for us in real-world usage, as we are hitting the 1MB template size limit
when using nested stacks.

I understand this PR has been inactive for a while.
If this approach is not preferred or the PR is considered outdated, I’m very happy to:

  • rebase it onto the latest main, or
  • open a fresh PR that supersedes this one, or
  • make any changes you’d recommend to move this forward.

Any guidance on the preferred next step (or the right reviewers) would be greatly appreciated.

Copy link
Copy Markdown
Contributor

@go-to-k go-to-k left a comment

Choose a reason for hiding this comment

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

Thanks for this PR. Left a minor comment.

Copy link
Copy Markdown
Contributor

@go-to-k go-to-k Jan 16, 2026

Choose a reason for hiding this comment

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

This test doesn't need to be a reference test for nested stacks.

Also, suppressTemplateIndentation property does not appear on the CFn template, so it would be better to check in assertions whether template indentation is suppressed.

It should be able to be simplified as follows. (In that case, the filename would be changed too.)

For example:

const app = new cdk.App();
const stack = new cdk.Stack(app, 'ParentStack');

const nested = new cdk.NestedStack(stack, 'NestedSuppressIndentation', { suppressTemplateIndentation: true });
new s3.Bucket(nested, 'Bucket'); // dummy

const testCase = new integ.IntegTest(app, 'NestedSuppressIndentationTest', {
  testCases: [stack],
});

const nestedChild = nested.node.defaultChild as cdk.CfnStack;
const nestedTemplateUrl = nestedChild.templateUrl!; // Nested stacks must have the templateUrl

const apiCall = testCase.assertions.awsApiCall('S3', 'getObject', {
  Bucket: cdk.Fn.select(3, cdk.Fn.split('/', nestedTemplateUrl)),
  Key: cdk.Fn.select(4, cdk.Fn.split('/', nestedTemplateUrl)),
});

apiCall.expect(integ.ExpectedResult.objectLike({ Body: '{"Resources":{"Bucket83908E77":{"Type":"AWS::S3::Bucket","UpdateReplacePolicy":"Retain","DeletionPolicy":"Retain"}}}' }));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comment, I've updated the test per your suggestions

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jan 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 19, 2026

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
Please try merge from main to avoid findings unrelated to the PR.


TestsPassed ✅SkippedFailed
Security Guardian Results72 ran72 passed
TestResult
No test annotations available

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 19, 2026

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
Please try merge from main to avoid findings unrelated to the PR.


TestsPassed ✅SkippedFailed
Security Guardian Results with resolved templates72 ran72 passed
TestResult
No test annotations available

Copy link
Copy Markdown
Contributor

@go-to-k go-to-k left a comment

Choose a reason for hiding this comment

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

Thanks for the change! LGTM.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 20, 2026
vishaalmehrishi
vishaalmehrishi previously approved these changes Feb 2, 2026
@vishaalmehrishi vishaalmehrishi self-assigned this Feb 2, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Feb 2, 2026

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Feb 2, 2026

Merge Queue Status

🚫 The pull request has left the queue (rule: default-squash) at c880e87

This pull request spent 5 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

For security reasons, Mergify can't update this pull request. Try updating locally.
GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/pr-linter.yml without workflows permission

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

@mergify mergify Bot dismissed vishaalmehrishi’s stale review February 2, 2026 12:55

Pull request has been modified.

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Feb 2, 2026

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify Bot merged commit d629b15 into aws:main Feb 2, 2026
25 of 26 checks passed
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Feb 2, 2026

Merge Queue Status

✅ The pull request has been merged at d1d5bae

This pull request spent 5 seconds in the queue, with no time running CI.
The checks were run in-place.

Required conditions to merge

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 2, 2026

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Feb 2, 2026
@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core: Nested Stack templates cannot be suppressed natively by the CDK

6 participants