Skip to content

Commit 8758f3c

Browse files
authored
fix(aws-cdk): warn when legacy exports are used (#931)
This PR adds a prominent deprecation warning for legacy exports from the `aws-cdk` package. These exports were never officially supported and are scheduled for removal after 2026-03-01. ## Changes - Added a warning message that displays when legacy exports are imported - The warning directs users to migrate to the official CDK Toolkit Library - Includes an environment variable `CDK_DISABLE_LEGACY_EXPORT_WARNING=1` to disable the warning if needed - References issue #310 for more information The warning uses ANSI color codes to create a visually prominent yellow banner that clearly communicates the deprecation timeline and migration path. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
1 parent dd641b0 commit 8758f3c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/aws-cdk/lib/legacy-exports.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,24 @@ export const {
8686
data,
8787
prefix,
8888
} = legacy;
89+
90+
if (!process.env.CDK_DISABLE_LEGACY_EXPORT_WARNING) {
91+
// eslint-disable-next-line no-console
92+
console.warn([
93+
'',
94+
'\x1b[33m█████████████████████████████████████████████████████████████████████████\x1b[0m',
95+
'\x1b[33m█ █\x1b[0m',
96+
'\x1b[33m█ ⚠ WARNING: You are using LEGACY EXPORTS from the aws-cdk package! █\x1b[0m',
97+
'\x1b[33m█ █\x1b[0m',
98+
'\x1b[33m█ These exports were never officially supported and will be removed █\x1b[0m',
99+
'\x1b[33m█ after 2026-03-01. █\x1b[0m',
100+
'\x1b[33m█ Please migrate to using the official CDK Toolkit Library instead: █\x1b[0m',
101+
'\x1b[33m█ https://docs.aws.amazon.com/cdk/api/toolkit-lib/ █\x1b[0m',
102+
'\x1b[33m█ █\x1b[0m',
103+
'\x1b[33m█ For more information: https://github.com/aws/aws-cdk-cli/issues/310 █\x1b[0m',
104+
'\x1b[33m█ To disable this warning: CDK_DISABLE_LEGACY_EXPORT_WARNING=1 █\x1b[0m',
105+
'\x1b[33m█ █\x1b[0m',
106+
'\x1b[33m█████████████████████████████████████████████████████████████████████████\x1b[0m',
107+
'',
108+
].join('\n'));
109+
}

0 commit comments

Comments
 (0)