Skip to content

Commit 22dc717

Browse files
authoredMar 28, 2025··
feat(cx-api): declare support for CDK_TOOLKIT_VERSION env var (#33963)
### Reason for this change CDK apps have access to an informative env variable, containing the version of the CLI running the app. With the release of the CDK Toolkit Library, this value does not always represent what it should. As a future replacement, we are introducing a new env variable that will contain the version and package name of the package ### Description of changes Add a new env var name to `cx-api` to support a generic toolkit version. This value will contain the package name and version: "<package>@x.y.z", e.g "[email protected]" or "@aws-cdk/[email protected]" ### Describe any new or updated permissions being added n/a ### Description of how you validated changes n/a ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent e5f71db commit 22dc717

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
 

‎packages/aws-cdk-lib/cx-api/lib/cxapi.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export const DEFAULT_ACCOUNT_ENV = 'CDK_DEFAULT_ACCOUNT';
2020
export const DEFAULT_REGION_ENV = 'CDK_DEFAULT_REGION';
2121

2222
/**
23-
* Version of Cloud Assembly expected by CDK CLI.
23+
* Version of Cloud Assembly expected by CDK Toolkit.
24+
*
25+
* Despite it's name, this value applies to all version of the CDK Toolkit, not just the CLI.
2426
*
2527
* CLI started emitting this at 1.10.1
2628
*/
@@ -30,9 +32,17 @@ export const CLI_ASM_VERSION_ENV = 'CDK_CLI_ASM_VERSION';
3032
* Version of the CLI currently running.
3133
*
3234
* CLI started emitting this at 1.10.1
35+
* Will not be present if the CDK app is run by any Toolkit variation other than the CLI.
3336
*/
3437
export const CLI_VERSION_ENV = 'CDK_CLI_VERSION';
3538

39+
/**
40+
* Package & version of the CDK Toolkit running the app.
41+
*
42+
* In the format "<package>@x.y.z", e.g "aws-cdk@2.1006.0" or "@aws-cdk/toolkit-lib@1.0.0"
43+
*/
44+
export const TOOLKIT_VERSION_ENV = 'CDK_TOOLKIT_VERSION';
45+
3646
/**
3747
* If a context value is an object with this key, it indicates an error
3848
*/

0 commit comments

Comments
 (0)
Please sign in to comment.