@aws-cdk/toolkit-lib 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +16 -0
- package/README.md +432 -0
- package/build-info.json +4 -0
- package/db.json.gz +0 -0
- package/lib/actions/deploy/index.d.ts +178 -0
- package/lib/actions/deploy/index.js +78 -0
- package/lib/actions/deploy/private/deploy-options.d.ts +78 -0
- package/lib/actions/deploy/private/deploy-options.js +3 -0
- package/lib/actions/deploy/private/helpers.d.ts +15 -0
- package/lib/actions/deploy/private/helpers.js +41 -0
- package/lib/actions/deploy/private/index.d.ts +2 -0
- package/lib/actions/deploy/private/index.js +19 -0
- package/lib/actions/destroy/index.d.ts +17 -0
- package/lib/actions/destroy/index.js +3 -0
- package/lib/actions/diff/index.d.ts +83 -0
- package/lib/actions/diff/index.js +45 -0
- package/lib/actions/diff/private/helpers.d.ts +7 -0
- package/lib/actions/diff/private/helpers.js +20 -0
- package/lib/actions/diff/private/index.d.ts +1 -0
- package/lib/actions/diff/private/index.js +18 -0
- package/lib/actions/import/index.d.ts +21 -0
- package/lib/actions/import/index.js +3 -0
- package/lib/actions/index.d.ts +6 -0
- package/lib/actions/index.js +23 -0
- package/lib/actions/list/index.d.ts +7 -0
- package/lib/actions/list/index.js +3 -0
- package/lib/actions/rollback/index.d.ts +39 -0
- package/lib/actions/rollback/index.js +3 -0
- package/lib/actions/synth/index.d.ts +12 -0
- package/lib/actions/synth/index.js +3 -0
- package/lib/actions/watch/index.d.ts +35 -0
- package/lib/actions/watch/index.js +3 -0
- package/lib/actions/watch/private/helpers.d.ts +4 -0
- package/lib/actions/watch/private/helpers.js +8 -0
- package/lib/actions/watch/private/index.d.ts +1 -0
- package/lib/actions/watch/private/index.js +18 -0
- package/lib/api/aws-auth/index.d.ts +1 -0
- package/lib/api/aws-auth/index.js +18 -0
- package/lib/api/aws-auth/types.d.ts +32 -0
- package/lib/api/aws-auth/types.js +3 -0
- package/lib/api/aws-cdk.d.ts +25 -0
- package/lib/api/aws-cdk.js +9329 -0
- package/lib/api/aws-cdk.js.map +7 -0
- package/lib/api/cloud-assembly/index.d.ts +3 -0
- package/lib/api/cloud-assembly/index.js +20 -0
- package/lib/api/cloud-assembly/private/cached-source.d.ts +15 -0
- package/lib/api/cloud-assembly/private/cached-source.js +25 -0
- package/lib/api/cloud-assembly/private/context-aware-source.d.ts +45 -0
- package/lib/api/cloud-assembly/private/context-aware-source.js +89 -0
- package/lib/api/cloud-assembly/private/exec.d.ts +13 -0
- package/lib/api/cloud-assembly/private/exec.js +56 -0
- package/lib/api/cloud-assembly/private/identity-source.d.ts +10 -0
- package/lib/api/cloud-assembly/private/identity-source.js +17 -0
- package/lib/api/cloud-assembly/private/index.d.ts +8 -0
- package/lib/api/cloud-assembly/private/index.js +25 -0
- package/lib/api/cloud-assembly/private/prepare-source.d.ts +52 -0
- package/lib/api/cloud-assembly/private/prepare-source.js +166 -0
- package/lib/api/cloud-assembly/private/source-builder.d.ts +29 -0
- package/lib/api/cloud-assembly/private/source-builder.js +121 -0
- package/lib/api/cloud-assembly/private/stack-assembly.d.ts +30 -0
- package/lib/api/cloud-assembly/private/stack-assembly.js +94 -0
- package/lib/api/cloud-assembly/private/stack-selectors.d.ts +2 -0
- package/lib/api/cloud-assembly/private/stack-selectors.js +8 -0
- package/lib/api/cloud-assembly/source-builder.d.ts +113 -0
- package/lib/api/cloud-assembly/source-builder.js +3 -0
- package/lib/api/cloud-assembly/stack-selector.d.ts +81 -0
- package/lib/api/cloud-assembly/stack-selector.js +64 -0
- package/lib/api/cloud-assembly/types.d.ts +7 -0
- package/lib/api/cloud-assembly/types.js +3 -0
- package/lib/api/errors.d.ts +44 -0
- package/lib/api/errors.js +82 -0
- package/lib/api/io/index.d.ts +2 -0
- package/lib/api/io/index.js +19 -0
- package/lib/api/io/io-host.d.ts +15 -0
- package/lib/api/io/io-host.js +3 -0
- package/lib/api/io/io-message.d.ts +59 -0
- package/lib/api/io/io-message.js +3 -0
- package/lib/api/io/private/codes.d.ts +37 -0
- package/lib/api/io/private/codes.js +48 -0
- package/lib/api/io/private/index.d.ts +6 -0
- package/lib/api/io/private/index.js +23 -0
- package/lib/api/io/private/level-priority.d.ts +11 -0
- package/lib/api/io/private/level-priority.js +33 -0
- package/lib/api/io/private/logger.d.ts +40 -0
- package/lib/api/io/private/logger.js +211 -0
- package/lib/api/io/private/messages.d.ts +64 -0
- package/lib/api/io/private/messages.js +159 -0
- package/lib/api/io/private/timer.d.ts +29 -0
- package/lib/api/io/private/timer.js +54 -0
- package/lib/api/io/private/types.d.ts +25 -0
- package/lib/api/io/private/types.js +3 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +25 -0
- package/lib/index_bg.wasm +0 -0
- package/lib/toolkit/index.d.ts +1 -0
- package/lib/toolkit/index.js +18 -0
- package/lib/toolkit/private/index.d.ts +9 -0
- package/lib/toolkit/private/index.js +3 -0
- package/lib/toolkit/toolkit.d.ts +142 -0
- package/lib/toolkit/toolkit.js +644 -0
- package/package.json +147 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
AWS Cloud Development Kit (AWS CDK)
|
|
2
|
+
Copyright 2018-2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
|
|
16
|
+
Third party attributions of this package can be found in the THIRD_PARTY_LICENSES file
|
package/README.md
ADDED
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
# AWS CDK Toolkit Library
|
|
2
|
+
<!--BEGIN STABILITY BANNER-->
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
> 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
|
+
|
|
19
|
+
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
|
+
|
|
21
|
+
## Get started with the AWS CDK Toolkit Library
|
|
22
|
+
|
|
23
|
+
### Step 1: Install the CDK Toolkit Library
|
|
24
|
+
|
|
25
|
+
Add the `@aws-cdk/toolkit-lib` package to your code base:
|
|
26
|
+
|
|
27
|
+
```console
|
|
28
|
+
npm install --save @aws-cdk/toolkit-lib
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Step 2: Create and configure a new instance of the CDK Toolkit
|
|
32
|
+
|
|
33
|
+
You will use the CDK Toolkit instance to define the actions to perform on your CDK app.
|
|
34
|
+
The following is an example of creating a new instance of the CDK Toolkit:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { Toolkit } from '@aws-cdk/toolkit-lib';
|
|
38
|
+
|
|
39
|
+
const cdk = new Toolkit({
|
|
40
|
+
// Optional configuration options go here
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
You can optionally customize the CDK Toolkit instance during creation.
|
|
45
|
+
For instructions, see [Configure your CDK Toolkit instance](#configure-your-cdk-toolkit-instance).
|
|
46
|
+
|
|
47
|
+
### Step 3: Create a cloud assembly source for your CDK app
|
|
48
|
+
|
|
49
|
+
A _Cloud Assembly_ represents the AWS CloudFormation templates and deployment artifacts that are produced from a CDK app.
|
|
50
|
+
With the CDK, the Cloud Assembly is generated during synthesis and is what gets deployed to provision your infrastructure.
|
|
51
|
+
The CDK Toolkit creates a _Cloud Assembly_ from a _Cloud Assembly Source_.
|
|
52
|
+
|
|
53
|
+
The _Cloud Assembly Source_ is a fundamental CDK Toolkit component that defines instructions for creating a _Cloud Assembly_ from your app.
|
|
54
|
+
For example, CDK apps may need to be synthesized multiple times with additional context values before they are ready.
|
|
55
|
+
Once created, you can use your _Cloud Assembly Source_ to perform actions with the CDK Toolkit.
|
|
56
|
+
|
|
57
|
+
The following is an example of creating a _Cloud Assembly Source_ using an inline _assembly builder function_:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import * as core from 'aws-cdk-lib/core';
|
|
61
|
+
|
|
62
|
+
declare const cdk: Toolkit;
|
|
63
|
+
|
|
64
|
+
const cx = cdk.fromAssemblyBuilder(async () => {
|
|
65
|
+
const app = new core.App();
|
|
66
|
+
|
|
67
|
+
// Define your stacks here
|
|
68
|
+
new MyStack(app, 'MyStack');
|
|
69
|
+
|
|
70
|
+
return app.synth();
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
For more details, see [Cloud Assembly Sources](#cloud-assembly-sources).
|
|
75
|
+
|
|
76
|
+
### Step 4: Define programmatic actions in for your CDK app
|
|
77
|
+
|
|
78
|
+
Now that you’ve created a CDK Toolkit instance and Cloud Assembly Source, you can start to define programmatic actions.
|
|
79
|
+
The following is a basic example that creates a deployment of the `MyStack` stack:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
declare const cdk: Toolkit;
|
|
83
|
+
declare const cx: ICloudAssemblySource;
|
|
84
|
+
|
|
85
|
+
await toolkit.deploy(cloudAssembly, {
|
|
86
|
+
stacks: {
|
|
87
|
+
strategy: StackSelectionStrategy.PATTERN_MUST_MATCH,
|
|
88
|
+
patterns: ["MyStack"],
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Step 5: Customize the CDK Toolkit further
|
|
94
|
+
|
|
95
|
+
You can configure and customize the CDK Toolkit further for your needs:
|
|
96
|
+
|
|
97
|
+
* **Messages and requests** - The CDK Toolkit outputs a structured flow of messages and requests back to the client, such as a human actor or application using the CDK Toolkit. For instructions, see [Messages & interaction](#messages--interaction).
|
|
98
|
+
* **Error handling** - The CDK Toolkit uses structured errors to help you identify and handle issues during Toolkit operations. You can integrate error handling into your app or customize them further for your needs. For instructions, see [Error handling](#error-handling).
|
|
99
|
+
|
|
100
|
+
## Actions
|
|
101
|
+
|
|
102
|
+
The CDK Toolkit Library provides programmatic interfaces for the following lifecycle actions.
|
|
103
|
+
Support for further actions will be extended over time.
|
|
104
|
+
|
|
105
|
+
### synth
|
|
106
|
+
|
|
107
|
+
Synthesis is the process of producing AWS CloudFormation templates and deployment artifacts from a CDK app.
|
|
108
|
+
For an introduction to synthesis, see [Configure and perform CDK stack synthesis](https://docs.aws.amazon.com/cdk/v2/guide/configure-synth.html).
|
|
109
|
+
In the CDK Toolkit Library, you can use synth to produce a reusable snapshot of a _Cloud Assembly Source_.
|
|
110
|
+
This is useful if the same source will be used with multiple Toolkit actions,
|
|
111
|
+
because the _Cloud Assembly_ does not have to be produced multiple times.
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
declare const cdk: Toolkit;
|
|
115
|
+
declare const cx: ICloudAssemblySource;
|
|
116
|
+
|
|
117
|
+
// Will run the CDK app defined in the Cloud Assembly Source
|
|
118
|
+
// This is an expensive and slow operation
|
|
119
|
+
const cxSnap = await cdk.synth(cx, {
|
|
120
|
+
validateStacks: true, // set to `false` to not throw an error if stacks in the assembly contain error annotations
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
// Will use the previously synthesized Cloud Assembly
|
|
124
|
+
// This is now a cheap and fast operation
|
|
125
|
+
const cxSnap = await cdk.list(cxSnap);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
You can also use the snapshot to query information about the synthesized _Cloud Assembly_:
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
declare const cloudAssembly = await cxSnap.produce();
|
|
132
|
+
declare const template = cloudAssembly.getStack("my-stack").template;
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### list
|
|
136
|
+
|
|
137
|
+
The list operation provides high-level information about the stacks and their dependencies within a CDK application.
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
declare const cdk: Toolkit;
|
|
141
|
+
declare const cx: ICloudAssemblySource;
|
|
142
|
+
|
|
143
|
+
const details = await cdk.list(cx, {
|
|
144
|
+
// optionally provide a stack selector to control which stacks are returned
|
|
145
|
+
stacks: {
|
|
146
|
+
strategy: StackSelectionStrategy.PATTERN_MUST_MATCH,
|
|
147
|
+
patterns: ["my-stack"],
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### deploy
|
|
153
|
+
|
|
154
|
+
Deployment is the process of provisioning or updating your infrastructure in AWS using the CloudFormation templates and assets produced during synthesis.
|
|
155
|
+
For an introduction to deploying, see [Deploy AWS CDK applications](https://docs.aws.amazon.com/cdk/v2/guide/deploy.html).
|
|
156
|
+
With the CDK Toolkit Library, you can programmatically control deployments, including stack selection, rollback behavior, and deployment monitoring.
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
declare const cdk: Toolkit;
|
|
160
|
+
declare const cx: ICloudAssemblySource;
|
|
161
|
+
|
|
162
|
+
await cdk.deploy(cx, {
|
|
163
|
+
deploymentMethod: { method: "direct " }, // use direct deployments instead of change-sets
|
|
164
|
+
parameters: StackParameters.exactly({ /* ... */ }), // provide new values for stack parameters
|
|
165
|
+
})
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### rollback
|
|
169
|
+
|
|
170
|
+
Rollback returns a stack to its last stable state when a deployment fails or needs to be reversed.
|
|
171
|
+
The CDK Toolkit Library allows you to programmatically roll back failed deployments.
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
declare const cdk: Toolkit;
|
|
175
|
+
declare const cx: ICloudAssemblySource;
|
|
176
|
+
|
|
177
|
+
await cdk.rollback(cx, {
|
|
178
|
+
orphanFailedResources: false, // set to `true` to automatically orphan all failed resources
|
|
179
|
+
})
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### watch
|
|
183
|
+
|
|
184
|
+
Use the watch feature to continuously monitor your CDK app for local changes and automatically perform deployments or hotswaps.
|
|
185
|
+
This will create a file watcher that is terminated once your code exits.
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
declare const cdk: Toolkit;
|
|
189
|
+
declare const cx: ICloudAssemblySource;
|
|
190
|
+
|
|
191
|
+
await cdk.watch(cx, {
|
|
192
|
+
include: [], // optionally provide a list of file path patterns to watch
|
|
193
|
+
exclude: [], // or exclude files by file path patterns
|
|
194
|
+
})
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### destroy
|
|
198
|
+
|
|
199
|
+
Use the destroy feature to remove CDK stacks and their associated resources from AWS:
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
declare const cdk: Toolkit;
|
|
203
|
+
declare const cx: ICloudAssemblySource;
|
|
204
|
+
|
|
205
|
+
await cdk.destroy(cx, {
|
|
206
|
+
// optionally provide a stack selector to control which stacks are destroyed
|
|
207
|
+
stacks: {
|
|
208
|
+
strategy: StackSelectionStrategy.PATTERN_MUST_MATCH,
|
|
209
|
+
patterns: ["my-stack"],
|
|
210
|
+
}
|
|
211
|
+
})
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Configure your CDK Toolkit instance
|
|
215
|
+
|
|
216
|
+
### Messages & interaction
|
|
217
|
+
|
|
218
|
+
The CDK Toolkit outputs a structured flow of _messages_ and _requests_ back to a client integrating with the Toolkit.
|
|
219
|
+
|
|
220
|
+
* **Messages** - Informs the client about the progress and state of operations. Does not require a response.
|
|
221
|
+
* **Requests** - Special messages that allow the client to respond. If no response is given, the Toolkit will use a default response.
|
|
222
|
+
|
|
223
|
+
The CDK Toolkit Library outputs messages and requests through an `IoHost`.
|
|
224
|
+
Think of the `IoHost` as the blueprint that defines how communication works for the CDK Toolkit.
|
|
225
|
+
For each message or request, the Toolkit calls either the `notify` or `requestResponse` method of the `IoHost`.
|
|
226
|
+
|
|
227
|
+
#### Customizing the IoHost
|
|
228
|
+
|
|
229
|
+
You can configure a custom `IoHost` to control the flow of information and integrate them into your workflows and automation.
|
|
230
|
+
The following is an example implementation that simply logs all message objects to stdout:
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
const toolkit = new toolkitLib.Toolkit({
|
|
234
|
+
ioHost: {
|
|
235
|
+
notify: async function (msg) {
|
|
236
|
+
console.log(msg);
|
|
237
|
+
},
|
|
238
|
+
requestResponse: async function (msg) {
|
|
239
|
+
console.log(msg);
|
|
240
|
+
return msg.defaultResponse;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
})
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
The CDK Toolkit awaits the completion of each call, allowing clients to perform asynchronous operations like HTTP requests when handling messages or requests.
|
|
247
|
+
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
|
+
If your implementation doesn’t provide a response to a request, the CDK Toolkit proceeds with a default value.
|
|
249
|
+
|
|
250
|
+
#### Default IoHost
|
|
251
|
+
|
|
252
|
+
By default the CDK Toolkit Library will use a `IoHost` implantation that mimics the behavior of the AWS CDK Toolkit CLI.
|
|
253
|
+
|
|
254
|
+
### Configure your AWS profile
|
|
255
|
+
|
|
256
|
+
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:
|
|
258
|
+
|
|
259
|
+
```ts
|
|
260
|
+
import { Toolkit } from '@aws-cdk/toolkit-lib';
|
|
261
|
+
|
|
262
|
+
const cdk = new Toolkit({
|
|
263
|
+
sdkConfig: { profile: "my-profile" },
|
|
264
|
+
});
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Configure a proxy for SDK calls
|
|
268
|
+
|
|
269
|
+
The Toolkit internally uses AWS SDK Clients to make necessary API calls to AWS.
|
|
270
|
+
You can specify a proxy configuration for all SDK calls:
|
|
271
|
+
|
|
272
|
+
```ts
|
|
273
|
+
import { Toolkit } from '@aws-cdk/toolkit-lib';
|
|
274
|
+
|
|
275
|
+
const cdk = new Toolkit({
|
|
276
|
+
sdkConfig: {
|
|
277
|
+
httpOptions: {
|
|
278
|
+
proxyAddress: "https://example.com",
|
|
279
|
+
caBundlePath: "path/to/ca/bundle",
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Configure Toolkit Actions
|
|
286
|
+
|
|
287
|
+
Every action the CDK Toolkit Library provides has its own options.
|
|
288
|
+
However some arguments and options are shared between multiple actions.
|
|
289
|
+
|
|
290
|
+
## Cloud Assembly Sources
|
|
291
|
+
|
|
292
|
+
The _Cloud Assembly Source_ is a fundamental CDK Toolkit component that defines instructions for creating a _Cloud Assembly_ from your app.
|
|
293
|
+
For example, CDK apps may need to be synthesized multiple times with additional context values before they are ready.
|
|
294
|
+
Once created, you can use your _Cloud Assembly Source_ to perform actions with the CDK Toolkit.
|
|
295
|
+
|
|
296
|
+
Every _Cloud Assembly Source_ must implement the `ICloudAssemblySource` interface. This allows you to define your own custom sources.
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
interface ICloudAssemblySource {
|
|
300
|
+
produce(): Promise<cxapi.CloudAssembly>;
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
For convenience the CDK Toolkit Library offers a range of standard sources, which can be instantiated using the `fromXyz()` helper methods on your toolkit instance.
|
|
305
|
+
|
|
306
|
+
Most existing CDK apps are written as JavaScript apps or in a jsii language.
|
|
307
|
+
With the CDK Toolkit Library you can use these CDK apps by providing the `app` string as found in a `cdk.json` file:
|
|
308
|
+
|
|
309
|
+
```ts
|
|
310
|
+
declare const cdk: Toolkit;
|
|
311
|
+
|
|
312
|
+
// TypeScript
|
|
313
|
+
await cdk.fromCdkApp("ts-node app.ts");
|
|
314
|
+
|
|
315
|
+
// Python
|
|
316
|
+
await cdk.fromCdkApp("python app.py");
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Alternatively a inline `AssemblyBuilder` function can be used to build a CDK app on-the-fly.
|
|
320
|
+
|
|
321
|
+
```ts
|
|
322
|
+
declare const cdk: Toolkit;
|
|
323
|
+
|
|
324
|
+
const cx = cdk.fromAssemblyBuilder(async () => {
|
|
325
|
+
const app = new core.App();
|
|
326
|
+
|
|
327
|
+
// Define your stacks here
|
|
328
|
+
new MyStack(app, 'MyStack');
|
|
329
|
+
|
|
330
|
+
return app.synth();
|
|
331
|
+
});
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Existing _Cloud Assembly_ directories can be used as source like this:
|
|
335
|
+
|
|
336
|
+
```ts
|
|
337
|
+
declare const cdk: Toolkit;
|
|
338
|
+
|
|
339
|
+
const cx = await cdk.fromAssemblyDirectory("cdk.out");
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## Stack selection
|
|
343
|
+
|
|
344
|
+
Most actions of the CDK Toolkit take a `StackSelector` to configure with stacks should be used for the action.
|
|
345
|
+
A `StackSelector` and some optional additional values.
|
|
346
|
+
|
|
347
|
+
To select all stacks use the `ALL_STACKS` strategy:
|
|
348
|
+
|
|
349
|
+
```ts
|
|
350
|
+
const allStacks = { strategy: StackSelectionStrategy.ALL_STACKS };
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
To select only the top-level stacks from the main assembly, use the `MAIN_ASSEMBLY` strategy:
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
const mainStacks = { strategy: StackSelectionStrategy.MAIN_ASSEMBLY };
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
The `ONLY_SINGLE` strategy allows you to ensure a given assembly contains exactly one stack, and select it:
|
|
360
|
+
|
|
361
|
+
```ts
|
|
362
|
+
const mainStacks = { strategy: StackSelectionStrategy.ONLY_SINGLE };
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
To select stacks by IDs, use `PATTERN_MUST_MATCH` with an additional `patterns` property.
|
|
366
|
+
If no stacks are matched, this strategy will throw an error.
|
|
367
|
+
|
|
368
|
+
```ts
|
|
369
|
+
const matchStacks = {
|
|
370
|
+
strategy: StackSelectionStrategy.PATTERN_MUST_MATCH,
|
|
371
|
+
patterns: ["MyStack"],
|
|
372
|
+
};
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
You can optionally declare that the provided patterns must match exactly one stack by using `PATTERN_MUST_MATCH_SINGLE`,
|
|
376
|
+
or can match none at all by using `PATTERN_MATCH`.
|
|
377
|
+
|
|
378
|
+
## Error handling
|
|
379
|
+
|
|
380
|
+
The CDK Toolkit uses structured errors to help you identify and handle issues during CDK Toolkit operations.
|
|
381
|
+
These errors provide detailed information about what went wrong and why.
|
|
382
|
+
|
|
383
|
+
Each error includes one of the following sources, which represents where the error originates from:
|
|
384
|
+
|
|
385
|
+
* toolkit - Error originates from the CDK Toolkit.
|
|
386
|
+
* user - Error originates from the user, such as configuration or user input errors.
|
|
387
|
+
|
|
388
|
+
Each error also includes a specific error type, such as authentication or validation, and a descriptive message. You can catch and handle these errors in your application to provide appropriate responses or fallback behaviors. If the CDK Toolkit throws other exceptions, they are bugs and you should report them by raising an issue.s
|
|
389
|
+
|
|
390
|
+
### How to handle errors
|
|
391
|
+
|
|
392
|
+
In the CDK Toolkit Library, all errors are thrown as regular exceptions.
|
|
393
|
+
|
|
394
|
+
Use helper methods provided by the CDK Toolkit to detect error types.
|
|
395
|
+
Even though errors are typed, do not rely on instanceof checks because they can behave unexpectedly when working with multiple copies of the same package.
|
|
396
|
+
|
|
397
|
+
The following is a basic example:
|
|
398
|
+
|
|
399
|
+
```ts
|
|
400
|
+
declare const cdk: Toolkit;
|
|
401
|
+
declare const cx: ICloudAssemblySource;
|
|
402
|
+
|
|
403
|
+
try {
|
|
404
|
+
// Attempt a CDK Toolkit operation
|
|
405
|
+
const deployment = await cdk.deploy(cloudAssembly, {
|
|
406
|
+
stacks: ['MyStack']
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
} catch (error) {
|
|
410
|
+
|
|
411
|
+
if (ToolkitError.isAuthenticationError(error)) {
|
|
412
|
+
// Handle credential issues
|
|
413
|
+
console.error('AWS credentials error:', error.message);
|
|
414
|
+
|
|
415
|
+
} else if (ToolkitError.isAssemblyError(error)) {
|
|
416
|
+
// Handle errors from your CDK app
|
|
417
|
+
console.error('CDK app error:', error.message);
|
|
418
|
+
|
|
419
|
+
} else if (ToolkitError.isContextProviderError(error)) {
|
|
420
|
+
// Handle errors from context providers
|
|
421
|
+
console.error('Context provider error:', error.message);
|
|
422
|
+
|
|
423
|
+
} else if (ToolkitError.isToolkitError(error)) {
|
|
424
|
+
// Handle all other Toolkit errors
|
|
425
|
+
console.error('Generic Toolkit error:', error.message);
|
|
426
|
+
|
|
427
|
+
} else {
|
|
428
|
+
// Handle unexpected errors
|
|
429
|
+
console.error('Unexpected error:', error);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
```
|
package/build-info.json
ADDED
package/db.json.gz
ADDED
|
Binary file
|