CDK update - June 2026

CDK update - June 2026

Hey CDK community! Here’s an update on everything that shipped in June 2026. 嘿,CDK 社区!以下是 2026 年 6 月发布的所有更新内容。

TL;DR

简要总结

Runtime.NODEJS_LATEST now resolves to Node.js 24.x — callback-style Lambda handlers will break. Action required if you use NODEJS_LATEST. On the positive side: the new cdk explore command gives you a visual web UI for browsing your Cloud Assembly, the experimental cdk validate command lets you run validation plugins without a full deploy cycle, and token resolution is ~25% faster. These features are available in aws-cdk-lib v2.258.0 through v2.260.0 and aws-cdk CLI v2.1126.0 through v2.1128.1. Full changelogs on GitHub Releases (Library | CLI). Runtime.NODEJS_LATEST 现在解析为 Node.js 24.x —— 回调风格(callback-style)的 Lambda 处理程序将会失效。如果您使用了 NODEJS_LATEST,则需要采取行动。好消息是:全新的 cdk explore 命令为您提供了一个可视化 Web UI 来浏览 Cloud Assembly;实验性的 cdk validate 命令允许您在无需完整部署周期的情况下运行验证插件;此外,令牌解析速度提升了约 25%。这些功能已在 aws-cdk-lib v2.258.0 至 v2.260.0 以及 aws-cdk CLI v2.1126.0 至 v2.1128.1 中提供。完整更新日志请见 GitHub Releases (Library | CLI)。


Major Features

主要功能

⚠️ Lambda Node.js 24.x — Action Required

⚠️ Lambda Node.js 24.x — 需要采取行动

Runtime.NODEJS_LATEST now resolves to nodejs24.x in every region (#38031). This affects Lambda functions and custom resources that use the default runtime. Runtime.NODEJS_LATEST 现在在所有区域均解析为 nodejs24.x (#38031)。这会影响使用默认运行时的 Lambda 函数和自定义资源。

What breaks: Node.js 24 removes support for callback-style asynchronous handlers. If your Lambda code uses (event, context, callback) => {...}, it will fail at runtime after the bump. 什么会失效: Node.js 24 移除了对回调风格异步处理程序的支持。如果您的 Lambda 代码使用了 (event, context, callback) => {...},在升级后它将在运行时失败。

What to do: Migrate to async handlers: async (event, context) => {...} Or pin your runtime explicitly: Runtime.NODEJS_22_X (or useLatestRuntimeVersion: false in NodejsFunction). 如何处理: 迁移到异步处理程序:async (event, context) => {...},或者显式锁定您的运行时:Runtime.NODEJS_22_X(或在 NodejsFunction 中设置 useLatestRuntimeVersion: false)。

// ❌ This will break on Node.js 24
exports.handler = (event, context, callback) => {
  callback(null, { statusCode: 200 });
};

// ✅ Use async instead
exports.handler = async (event, context) => {
  return { statusCode: 200 };
};

Lambda accepts runtime updates in place — existing functions synthesized with NODEJS_LATEST will see nodejs22.xnodejs24.x on the next deploy, no recreation needed. But callback-based handlers must be updated before upgrading. See the Node.js 24 launch blog for details. Lambda 支持原地更新运行时——使用 NODEJS_LATEST 合成的现有函数在下次部署时会自动从 nodejs22.x 升级到 nodejs24.x,无需重新创建。但基于回调的处理程序必须在升级前进行更新。详情请参阅 Node.js 24 发布博客。

cdk explore — Visual Cloud Assembly Browser

cdk explore — 可视化 Cloud Assembly 浏览器

A brand-new command that launches a local web server for exploring your synthesized Cloud Assembly (#1578, #1598): 一个全新的命令,用于启动本地 Web 服务器以探索您合成的 Cloud Assembly (#1578, #1598):

$ cdk explore

Browse stack resources, view synthesized templates, and navigate between your source and the generated CloudFormation — all in a visual interface built on Cloudscape (#1606). The same work also landed an LSP foundation that surfaces validation violations and CFN resources in your editor (#1592), CodeLens navigation with template resource locations (#1617), two-way template/source navigation (#1624), and diagnostics that refresh automatically when cdk.out changes (#1630). See the cdk-explorer README for the full feature set. 在基于 Cloudscape 构建的可视化界面中,您可以浏览堆栈资源、查看合成的模板,并在源代码与生成的 CloudFormation 之间进行导航 (#1606)。同样的工作还引入了 LSP 基础架构,可在编辑器中显示验证违规和 CFN 资源 (#1592)、提供带有模板资源位置的 CodeLens 导航 (#1617)、双向模板/源代码导航 (#1624),以及在 cdk.out 发生变化时自动刷新的诊断信息 (#1630)。完整功能集请参阅 cdk-explorer 的 README。

cdk validate — Standalone Validation Command

cdk validate — 独立验证命令

An experimental cdk validate command landed (#1527), letting you run validation plugins against your synthesized templates as a standalone step. A follow-up added --online mode (#1539), which dynamically fetches the latest validation rules from remote sources instead of relying on locally installed rule sets. The command is still experimental as it matures — watch the CLI changelog as it evolves. 实验性的 cdk validate 命令已发布 (#1527),允许您将针对合成模板运行验证插件作为一个独立的步骤。后续更新增加了 --online 模式 (#1539),该模式可从远程源动态获取最新的验证规则,而无需依赖本地安装的规则集。该命令目前仍处于实验阶段,随着其成熟,请关注 CLI 更新日志以获取最新进展。


Performance Improvements

性能改进

ImprovementImpactPR
Token resolution ~25% fasterSynthesis time reduced for token-heavy apps#37920
Performance counters for slow synthAuto-emits diagnostics when synthesis is slow#38004
Docker build cache skipBundling correctly skips rebuild when the image is already built#38134
改进项影响PR
令牌解析速度提升约 25%减少了令牌密集型应用的合成时间#37920
慢速合成性能计数器当合成缓慢时自动发出诊断信息#38004
Docker 构建缓存跳过当镜像已构建时,打包过程能正确跳过重新构建#38134

Combined with April/May’s file-fingerprinting improvements, large CDK apps now synthesize noticeably faster than they did three months ago. 结合 4 月/5 月的文件指纹识别改进,大型 CDK 应用现在的合成速度比三个月前有了显著提升。


Cross-Stack Reference Strength Controls

跨堆栈引用强度控制

Building on April/May’s Fn::GetStackOutput and weak cross-stack references, June added fine-grained control over reference strength (#37840), and CDK now recommends weak references when no explicit choice has been made (#38070). A fix also landed for weak references to list attributes (#37948). 在 4 月/5 月引入的 Fn::GetStackOutput 和弱跨堆栈引用的基础上,6 月增加了对引用强度的细粒度控制 (#37840),并且 CDK 现在在未明确选择时会推荐使用弱引用 (#37948)。针对列表属性的弱引用修复也已发布 (#37948)。

Set the app-wide default in cdk.json: 在 cdk.json 中设置全局默认值:

{
  "context": {
    "@aws-cdk/core:defaultCrossStackReferences": "weak"
  }
}

See Reference strength in the aws-cdk-lib README for the strong/both/weak comparison table and the recommended migration path out of the “deadly embrace.” 请参阅 aws-cdk-lib README 中的“引用强度”部分,查看强/双向/弱引用的对比表,以及摆脱“死亡拥抱”(deadly embrace)的推荐迁移路径。


Validation Framework Evolution

验证框架演进

The Validations framework introduced in April/May continues to mature with four improvements: 4 月/5 月引入的验证框架通过以下四项改进继续成熟:

  • New validation report schema — more structured, easier for CI/CD tools to consume (#37970) 新的验证报告架构 — 结构更清晰,更易于 CI/CD 工具使用 (#37970)
  • Plugins can create files in the cloud assembly — compliance tools can generate audit reports directly (#38007) 插件可在 Cloud Assembly 中创建文件 — 合规工具可直接生成审计报告 (#38007)
  • Suppressed violations included in validation-report.json — full audit trail of deliberately ignored issues (#38009) 被抑制的违规项包含在 validation-report.json 中 — 提供被刻意忽略问题的完整审计追踪 (#38009)
  • Scope added to IPolicyValidationContext — enables scope-based validation rules (#38006) 为 IPolicyValidationContext 添加了 Scope — 启用基于作用域的验证规则 (#38006)

CLI Improvements

CLI 改进

--debug-app and --debug-cli

--debug-app--debug-cli

The old --debug flag has been split into targeted options (#1604): --debug-app shows only synthesis-related output (your CDK app logic), while --debug-cli shows CLI internals. 旧的 --debug 标志已被拆分为针对性的选项 (#1604):--debug-app 仅显示与合成相关的输出(您的 CDK 应用逻辑),而 --debug-cli 则显示 CLI 的内部信息。

ECS and Custom Resource Failure Logs

ECS 和自定义资源失败日志

When deployments fail due to ECS service issues or custom resource Lambda errors, the CLI now automatically fetches and displays the relevant logs — no more switching to CloudWatch to find out what went wrong. Detailed ECS service and container-level logs landed in #1505, and custom resource Lambda logs in #1645. 当部署因 ECS 服务问题或自定义资源 Lambda 错误而失败时,CLI 现在会自动获取并显示相关日志——无需再切换到 CloudWatch 来查找问题所在。详细的 ECS 服务和容器级日志已在 #1505 中实现,自定义资源 Lambda 日志在 #1645 中实现。

Additional CLI Updates

其他 CLI 更新

  • Asset packaging dependencies reduced by ~48 — faster installs, smaller bundle, reduced supply chain risk (#1654) 资产打包依赖项减少约 48 个 — 安装更快、包体积更小、降低供应链风险 (#1654)
  • cdk init project name fix--project-name now correctly maps to generated files (#1644, TORIFUKUKaiou) cdk init 项目名称修复--project-name 现在能正确映射到生成的文件 (#1644, TORIFUKUKaiou)
  • Custom role session names — set CDK_ROLE_SESSION_NAME to control the assumed-role session name (#1672, UTKARSH698) 自定义角色会话名称 — 设置 CDK_ROLE_SESSION_NAME 以控制代入角色的会话名称 (#1672, UTKARSH698)
  • cdk list stdout fix — output no longer includes synthesis timing or dependency status lines, making it reliable for scripting (#1637, #1663) cdk list 标准输出修复 — 输出不再包含合成耗时或依赖状态行,使其更适合脚本编写 (#1637, #1663)
  • Telemetry proxy support — telemetry now respects configured network proxies (#1577) 遥测代理支持 — 遥测现在遵循配置的网络代理 (#1577)