You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(toolkit-lib): General Availability of the AWS CDK Toolkit Library (#553)
**📣 Today we are very happy to announce the General Availability of the
AWS CDK Toolkit Library 📣**
The AWS Cloud Development Kit (AWS CDK) Toolkit Library enables you to
perform CDK actions requiring programmatic access on AWS. You can use
the AWS CDK Toolkit Library to implement actions such as bootstrapping,
synthesizing, and deploying through code rather than command-line
interface (CLI) commands. With this library, you can create custom
tools, build specialized CLI applications, and integrate CDK
programmatic access capabilities into your development workflows.
📜 Reference documentation:
https://docs.aws.amazon.com/cdk/api/toolkit-lib/
📦 npm package: https://www.npmjs.com/package/@aws-cdk/toolkit-lib
👩🏻🏫 Guide:
https://docs.aws.amazon.com/cdk/v2/guide/toolkit-library.html
---
Even though the CDK Toolkit Library is now *generally available*, we
still want to hear from you and appreciate all feedback!
💬 [Provide feedback, ideas and request new
features](#154)
🐛 [Report a bug](https://github.com/aws/aws-cdk-cli/issues/new/choose)
---
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license
Copy file name to clipboardExpand all lines: README.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,9 +29,9 @@ If you have a support plan with AWS Support, you can also create a new [support
29
29
30
30
You may also find help on these community resources:
31
31
32
-
* Look through the [API Reference](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-construct-library.html) or [Developer Guide](https://docs.aws.amazon.com/cdk/latest/guide)
33
-
* The #aws-cdk Slack channel in [cdk.dev](https://cdk.dev)
34
-
* Ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/aws-cdk)
32
+
- Look through the [API Reference](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-construct-library.html) or [Developer Guide](https://docs.aws.amazon.com/cdk/latest/guide)
33
+
- The #aws-cdk Slack channel in [cdk.dev](https://cdk.dev)
34
+
- Ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/aws-cdk)
35
35
and tag it with `aws-cdk`
36
36
37
37
## Contributing
@@ -44,20 +44,20 @@ environment and submit code.
44
44
45
45
Here are the packages in this repository. See the README of each package for more information about it:
|[aws-cdk](./packages/aws-cdk/)| The CDK Toolkit CLI, main CLI interface to CDK projects. | Yes | Yes |
50
-
|[cdk](./packages/cdk/)| An alias for `aws-cdk` so you can run `npx cdk` even if it's not installed. | Yes | Yes |
51
-
|[cdk-assets v3](./packages/cdk-assets/)| CLI component handling asset uploads, also used as a CLI in [CDK Pipelines](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines-readme.html)| Yes | Yes |
52
-
|[@aws-cdk/cloud-assembly-schema](./packages/@aws-cdk//cloud-assembly-schema/)| The contract between the CDK construct library and the CDK toolkit| Yes | Yes |
|[aws-cdk](./packages/aws-cdk/)| The CDK Toolkit CLI, main CLI interface to CDK projects. | Yes | Yes|
50
+
|[@aws-cdk/toolkit-lib](./packages/@aws-cdk/toolkit-lib/)| A programmatic interface for the CDK Toolkit. | Yes | Yes|
51
+
|[cdk](./packages/cdk/)| An alias for `aws-cdk` so you can run `npx cdk` even if it's not installed. | Yes | Yes|
52
+
|[cdk-assets v3](./packages/cdk-assets/)| CLI component handling asset uploads, also used as a CLI in [CDK Pipelines](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines-readme.html)| Yes | Yes|
53
+
|[@aws-cdk/cloud-assembly-schema](./packages/@aws-cdk//cloud-assembly-schema/)|The contract between the CDK construct library and the CDK toolkit | Yes | Yes|
|[@aws-cdk/cli-lib-alpha](./packages/@aws-cdk/cli-lib-alpha/)| A deprecated attempt at building a programmatic interface for the CLI | Yes | No |
56
+
|[@aws-cdk/cli-plugin-contract](./packages/@aws-cdk/cli-plugin-contract/)| TypeScript types for CLI plugins. | Yes | Yes|
57
+
|[@aws-cdk/cdk-cli-wrapper](./packages/@aws-cdk/cdk-cli-wrapper/)| A deprecated attempt at building a programmatic interface for the CLI | No | No|
58
+
|[@aws-cdk/node-bundle](./packages/@aws-cdk/node-bundle/)| A tool to build CLI bundles that include license attributions. | No | Yes|
59
+
|[@aws-cdk/user-input-gen](./packages/@aws-cdk/user-input-gen/)| A build tool for the CLI and toolkit-lib. | No | Yes|
60
+
|[@aws-cdk/yarn-cling](./packages/@aws-cdk/yarn-cling/)| A deprecated build tool for the CLI. | No | No|
61
61
62
62
Every package comes with its own unit tests. There is a companion repository to this one containing the integration tests. You can find it here: <https://github.com/aws/aws-cdk-cli-testing>
63
63
@@ -70,4 +70,4 @@ released before it. We recommend you always keep the CLI version up-to-date to g
70
70
latest features.
71
71
72
72
For more details on the compatibility model and specific versions that work together,
> The APIs in this module are experimental and under active development.
9
-
> They are subject to non-backward compatible changes or removal in future versions.
10
-
> The package follows the [Semantic Versioning](https://semver.org/) model for [major version zero](https://semver.org/#spec-item-4).
11
-
> Accordingly, breaking changes will be introduced in minor versions and announced in the release notes.
12
-
> This means that while you may use them, you may need to update
13
-
> your source code when upgrading to a newer version of this package.
14
-
15
-
---
16
-
17
-
<!--END STABILITY BANNER-->
18
2
19
3
The AWS Cloud Development Kit (AWS CDK) Toolkit Library enables you to perform CDK actions requiring programmatic access on AWS. You can use the AWS CDK Toolkit Library to implement actions such as bootstrapping, synthesizing, and deploying through code rather than command-line interface (CLI) commands. With this library, you can create custom tools, build specialized CLI applications, and integrate CDK programmatic access capabilities into your development workflows.
20
4
@@ -54,7 +38,7 @@ The _Cloud Assembly Source_ is a fundamental CDK Toolkit component that defines
54
38
For example, CDK apps may need to be synthesized multiple times with additional context values before they are ready.
55
39
Once created, you can use your _Cloud Assembly Source_ to perform actions with the CDK Toolkit.
56
40
57
-
The following is an example of creating a _Cloud Assembly Source_ using an inline_assembly builder function_:
41
+
The following is an example of creating a _Cloud Assembly Source_ using the_assembly builder function_:
58
42
59
43
```ts
60
44
import*ascorefrom'aws-cdk-lib/core';
@@ -112,24 +96,25 @@ because the _Cloud Assembly_ does not have to be produced multiple times.
112
96
113
97
```ts
114
98
declareconst cdk:Toolkit;
115
-
declareconstcx:ICloudAssemblySource;
99
+
declareconstsource:ICloudAssemblySource;
116
100
117
101
// Will run the CDK app defined in the Cloud Assembly Source
118
102
// This is an expensive and slow operation
119
-
const cxSnap =awaitcdk.synth(cx, {
103
+
// But its result can be stored and re-used
104
+
const cx =awaitcdk.synth(source, {
120
105
validateStacks: true, // set to `false` to not throw an error if stacks in the assembly contain error annotations
121
106
})
122
107
123
108
// Will use the previously synthesized Cloud Assembly
124
109
// This is now a cheap and fast operation
125
-
constcxSnap=awaitcdk.list(cxSnap);
110
+
constappDetails=awaitcdk.list(cx);
126
111
```
127
112
128
-
You can also use the snapshot to query information about the synthesized _Cloud Assembly_:
113
+
You can also query information about the synthesized _Cloud Assembly_:
Deployment is the process of provisioning or updating your infrastructure in AWS using the CloudFormation templates and assets produced during synthesis.
@@ -194,6 +196,28 @@ await cdk.watch(cx, {
194
196
})
195
197
```
196
198
199
+
### drift
200
+
201
+
Drift detection is crucial for maintaining infrastructure reliability.
202
+
It identifies when your deployed resources have been modified outside of your CDK code.
203
+
This allows you to quickly address unauthorized changes.
204
+
Such changes could lead to security vulnerabilities, compliance issues, or unexpected behavior in your cloud environment.
205
+
206
+
Use the drift operation to detect such drift in your CDK applications:
207
+
208
+
```ts
209
+
declareconst cdk:Toolkit;
210
+
declareconst cx:ICloudAssemblySource;
211
+
212
+
const stackDrifts =awaitcdk.drift(cx, {
213
+
// optionally provide a stack selector to control which stacks are checked for drift
Use the destroy feature to remove CDK stacks and their associated resources from AWS:
@@ -247,36 +271,40 @@ The CDK Toolkit awaits the completion of each call, allowing clients to perform
247
271
When you implement an `IoHost` interface, you can either process these communications (for example, logging to CloudWatch or prompting users for input) or return immediately without taking action.
248
272
If your implementation doesn’t provide a response to a request, the CDK Toolkit proceeds with a default value.
249
273
250
-
#### Default IoHost
274
+
#### Default `NonInteractiveIoHost`
251
275
252
-
By default the CDK Toolkit Library will use a `IoHost` implantation that mimics the behavior of the AWS CDK Toolkit CLI.
276
+
By default the CDK Toolkit Library will use a `NonInteractiveIoHost ` implementation that mimics the behavior of the AWS CDK Toolkit CLI.
277
+
This `NonInteractiveIoHost` is available for you as a base implementation to extend on.
253
278
254
279
### Configure your AWS profile
255
280
256
281
The Toolkit internally uses AWS SDK Clients to make necessary API calls to AWS.
257
-
Authentication configuration is loaded automatically from the environment, but you can explicitly specify the profile to be used:
282
+
Authentication configuration is loaded automatically from the environment, but you can explicitly specify the base credentials to be used:
0 commit comments