Skip to content

fix(core): only hash stack template files during validation, not entire cdk.out - #38628

Open
sanyamk23 wants to merge 5 commits into
aws:mainfrom
sanyamk23:fix/core-validation-perf
Open

fix(core): only hash stack template files during validation, not entire cdk.out#38628
sanyamk23 wants to merge 5 commits into
aws:mainfrom
sanyamk23:fix/core-validation-perf

Conversation

@sanyamk23

Copy link
Copy Markdown

Issue # (if applicable)

Closes #38614.
Fixes #38295.

Reason for this change

The pre-plugin tamper-detection snapshot called snapshotFileHashes(outdir), which recursively walked and hashed every file in the cloud assembly output directory (cdk.out). On long-lived working directories cdk.out accumulates stale asset.* staging directories (often hundreds of MB or even GB across millions of files), making every cdk synth/cdk deploy stall for minutes in validateTemplates while hashing files unrelated to the templates being validated.

Verified isolation: a fresh cdk.out synths in ~3.3s; the same dirty cdk.out with validation takes ~213s; --no-validation drops to ~2.3s. The cost is proportional to the total size of cdk.out, not the size of the current synth output.

Description of changes

Changed snapshotFileHashes() to accept an explicit list of file paths (the templateFullPath of each stack artifact handed to each validation plugin) instead of walking the entire outdir directory tree. Now only the stack template files are hashed — O(number of templates) instead of O(outdir size).

This also incidentally fixes #38295: the collectFilePaths() recursive directory walk (which crashed with EISDIR on symlink-to-directory entries) is no longer invoked, so symlinks in the assembly no longer reach hashFile().

Removed the now-unused collectFilePaths() function.

Updated the symlink regression test comment to reflect the new scoping behavior.

Describe any new or updated prerequisites

None.

Any behavior changes

The tamper-detection check now only covers stack template files (the same files passed to validation plugins), rather than every file in cdk.out. Untrusted plugins that modify template files are still caught and rejected with IllegalPluginOperation. Plugins that only modify non-template files (e.g. asset staging artifacts) are no longer treated as malicious.

Is this a breaking change to the CDK CLI?

No

Is this a breaking change to the library or any generated client interfaces?

No

The AWS Cognito API only accepts a domain prefix that starts and ends
with a lowercase alphanumeric character, contains only lowercase
alphanumeric characters and hyphens (not leading or trailing), and is
1-63 characters in length. The previous validation accepted any string
of lowercase alphanumerics and hyphens, which allowed invalid values
that fail at deploy time.

Fixes aws#38531
…Object]

The out-of-range error interpolated the Size object directly into the
message. Size has no toString(), so the value rendered as
[object Object] and gave no indication of what was actually passed.
Convert to mebibytes in the message, matching the conversion already
performed by the range check on the line above.

Fixes aws#38621
Allow customers to specify a KMS key to encrypt the DSQL cluster,
matching the underlying CfnCluster.KmsEncryptionKey property. Previously
users had to resort to the L1 construct or an escape hatch to set a
customer-managed key.

The new property uses kms.IKeyRef (the L1 reference interface) rather
than IKey, satisfying the awslint:prefer-ref-interface lint rule.

Fixes aws#38618
…re cdk.out

The pre-plugin tamper-detection snapshot called snapshotFileHashes(outdir),
which walked and hashed every file in the cloud assembly output directory. On
long-lived working directories cdk.out accumulates stale asset.* staging
directories (often hundreds of MB or GB of files), making synthesis stall for
minutes in validateTemplates while hashing files unrelated to the templates
being validated.

Instead collect only the templateFullPath values from the stack artifacts
handed to each plugin and hash just those. This makes the cost O(number of
templates) rather than O(outdir size), which also resolves aws#38295: the
collectFilePaths() directory walk that crashed on symlink-to-directory no
longer runs, so EISDIR can no longer occur.

Fixes aws#38614
Fixes aws#38295
@sanyamk23
sanyamk23 requested a review from a team as a code owner August 21, 2026 16:30
@sanyamk23
sanyamk23 deployed to automation August 21, 2026 16:30 — with GitHub Actions Active
@sanyamk23
sanyamk23 deployed to automation August 21, 2026 16:30 — with GitHub Actions Active
@github-actions github-actions Bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/medium Medium work item – several days of effort p0 labels Aug 21, 2026
@sanyamk23
sanyamk23 deployed to automation August 21, 2026 16:30 — with GitHub Actions Active
@aws-cdk-automation
aws-cdk-automation requested a review from a team August 21, 2026 16:30
@aws-cdk-automation aws-cdk-automation added the pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes. label Aug 21, 2026
Add new feature flag @aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2025
(FlagType.ApiDefault) and update Distribution renderViewerCertificate to
select TLSv1.2_2025 when the 2025 flag is enabled, falling back to 2021 then
2019.

Closes aws#38600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/medium Medium work item – several days of effort p0 pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes.

Projects

None yet

2 participants