Skip to content

feat(aws-cdk): remove legacy exports#1250

Merged
aws-cdk-automation merged 1 commit intomainfrom
mrgrain/feat/aws-cdk/remove-legacy-exports
Mar 24, 2026
Merged

feat(aws-cdk): remove legacy exports#1250
aws-cdk-automation merged 1 commit intomainfrom
mrgrain/feat/aws-cdk/remove-legacy-exports

Conversation

@mrgrain
Copy link
Copy Markdown
Contributor

@mrgrain mrgrain commented Mar 24, 2026

Relates to and resolves #310

In older versions of Node.js it was possible to import any file from any package. While the aws-cdk package is a CLI and has essentially no public API, a number of internal symbols were being imported by downstream users from deep subpaths. When the package started declaring its exports field in early 2025, a legacy compatibility layer was introduced (see aws/aws-cdk#33021) to avoid immediately breaking these consumers. Known subpath imports were mapped to a legacy-exports.ts shim that re-exported the symbols through the bundle, and a prominent runtime warning was added directing users to migrate to the official CDK Toolkit Library.

The announced end-of-life date of 2026-03-01 has now passed and users have had over four months to migrate since the deprecation warnings started appearing in November 2025. This change completes the removal by deleting the entire legacy compatibility system: the legacy-exports.ts entry point, the lib/legacy/ directory with its copied and wrapped versions of old code (logging, configuration, aws-auth, types), the legacy namespace re-export from index.ts, and all subpath export mappings in package.json that pointed to legacy-exports.js.

This also eliminates a significant amount of dead code. The legacy logging module was a frozen copy from November 2024. The legacy configuration module duplicated the entire CLI argument parsing and settings loading logic. The legacy aws-auth module wrapped the current SdkProvider with an older interface. None of this code was used by the CLI itself.

Users who still depend on these imports should migrate to the official CDK Toolkit Library which provides a stable, supported programmatic API. If a use case is not yet covered, please comment on #310.

⚠️ This is a breaking change for consumers of the unsanctioned subpath import. Unsanctioned subpath imports from the aws-cdk package (e.g. aws-cdk/lib/api/aws-auth, aws-cdk/lib/logging, aws-cdk/lib/settings) are no longer available.


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

@github-actions github-actions bot added the p2 label Mar 24, 2026
@aws-cdk-automation aws-cdk-automation requested a review from a team March 24, 2026 16:10
@mrgrain mrgrain changed the title feat(aws-cdk)!: remove legacy exports feat(aws-cdk): remove legacy exports Mar 24, 2026
@mrgrain mrgrain force-pushed the mrgrain/feat/aws-cdk/remove-legacy-exports branch from a53a242 to 8bb71e5 Compare March 24, 2026 16:24
@mrgrain mrgrain temporarily deployed to integ-approval March 24, 2026 16:24 — with GitHub Actions Inactive
@mrgrain mrgrain force-pushed the mrgrain/feat/aws-cdk/remove-legacy-exports branch from 8bb71e5 to 2d46fa3 Compare March 24, 2026 16:26
The deprecated legacy exports have reached their end-of-life date
of 2026-03-01. This removes all legacy compatibility shims, subpath
export mappings, and the legacy namespace re-export.

Unsanctioned subpath imports from the `aws-cdk`
package are no longer available. Migrate to the official CDK
Toolkit Library: https://docs.aws.amazon.com/cdk/api/toolkit-lib/
@mrgrain mrgrain force-pushed the mrgrain/feat/aws-cdk/remove-legacy-exports branch from 2d46fa3 to 18873b7 Compare March 24, 2026 16:30
@mrgrain mrgrain temporarily deployed to integ-approval March 24, 2026 16:30 — with GitHub Actions Inactive
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.07%. Comparing base (dce23a5) to head (18873b7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1250   +/-   ##
=======================================
  Coverage   88.07%   88.07%           
=======================================
  Files          74       74           
  Lines       10351    10351           
  Branches     1383     1383           
=======================================
  Hits         9117     9117           
  Misses       1208     1208           
  Partials       26       26           
Flag Coverage Δ
suite.unit 88.07% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue Mar 24, 2026
Merged via the queue into main with commit 37a8766 Mar 24, 2026
41 checks passed
@aws-cdk-automation aws-cdk-automation deleted the mrgrain/feat/aws-cdk/remove-legacy-exports branch March 24, 2026 17:17
github-merge-queue bot pushed a commit that referenced this pull request Mar 27, 2026
This was made possible by the migration in #1250, which moved all
callers to use `deploymentMethod` directly.

The `DeployStackOptions` interfaces in both `deploy-stack.ts` and
`deployments.ts` still carried several deprecated properties that served
as legacy compatibility shims, translating old-style options into the
newer `deploymentMethod` parameter. Since all callers have been migrated
to use `deploymentMethod` directly, these shims are no longer needed and
the translation code was dead weight.

This removes the deprecated `hotswap`, `hotswapPropertyOverrides`,
`execute`, `changeSetName`, and `ignoreNoStacks` properties from the
internal deployment interfaces, along with the compatibility translation
logic in `Deployments.deployStack()` and `deployStack()`. The
`CfnDeployOptions` interface in the CLI's `cdk-toolkit.ts` is cleaned up
accordingly, no longer passing the removed options through to
`Deployments`.

Tests are updated to use `deploymentMethod` directly instead of the
removed options.

### 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

⚠️ NOTICE: Deprecation and removal of legacy exports from AWS CDK CLI package after 2026-03-01

4 participants