aws-cdk 2.0.0-rc.8 → 2.2.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.
Files changed (238) hide show
  1. package/README.md +147 -2
  2. package/bin/cdk.d.ts +1 -0
  3. package/bin/cdk.js +109 -14
  4. package/build-info.json +2 -2
  5. package/lib/api/aws-auth/awscli-compatible.js +14 -7
  6. package/lib/api/aws-auth/sdk-provider.js +17 -24
  7. package/lib/api/aws-auth/sdk.d.ts +23 -0
  8. package/lib/api/aws-auth/sdk.js +43 -1
  9. package/lib/api/bootstrap/bootstrap-template.yaml +59 -26
  10. package/lib/api/bootstrap/deploy-bootstrap.js +2 -2
  11. package/lib/api/cloudformation-deployments.d.ts +17 -4
  12. package/lib/api/cloudformation-deployments.js +27 -22
  13. package/lib/api/cxapp/cloud-assembly.d.ts +19 -1
  14. package/lib/api/cxapp/cloud-assembly.js +79 -49
  15. package/lib/api/cxapp/cloud-executable.d.ts +6 -2
  16. package/lib/api/cxapp/cloud-executable.js +8 -4
  17. package/lib/api/cxapp/exec.js +8 -4
  18. package/lib/api/deploy-stack.d.ts +13 -0
  19. package/lib/api/deploy-stack.js +56 -25
  20. package/lib/api/hotswap/common.d.ts +55 -0
  21. package/lib/api/hotswap/common.js +53 -0
  22. package/lib/api/hotswap/ecs-services.d.ts +3 -0
  23. package/lib/api/hotswap/ecs-services.js +174 -0
  24. package/lib/api/hotswap/evaluate-cloudformation-template.d.ts +44 -0
  25. package/lib/api/hotswap/evaluate-cloudformation-template.js +247 -0
  26. package/lib/api/hotswap/lambda-functions.d.ts +9 -0
  27. package/lib/api/hotswap/lambda-functions.js +102 -0
  28. package/lib/api/hotswap/s3-bucket-deployments.d.ts +8 -0
  29. package/lib/api/hotswap/s3-bucket-deployments.js +113 -0
  30. package/lib/api/hotswap/stepfunctions-state-machines.d.ts +3 -0
  31. package/lib/api/hotswap/stepfunctions-state-machines.js +54 -0
  32. package/lib/api/hotswap-deployments.d.ts +21 -0
  33. package/lib/api/hotswap-deployments.js +161 -0
  34. package/lib/api/util/cloudformation/stack-activity-monitor.d.ts +1 -0
  35. package/lib/api/util/cloudformation/stack-activity-monitor.js +25 -6
  36. package/lib/api/util/cloudformation.d.ts +3 -1
  37. package/lib/api/util/cloudformation.js +6 -4
  38. package/lib/cdk-toolkit.d.ts +79 -28
  39. package/lib/cdk-toolkit.js +160 -28
  40. package/lib/context-providers/index.d.ts +10 -5
  41. package/lib/context-providers/index.js +38 -17
  42. package/lib/context-providers/keys.d.ts +11 -0
  43. package/lib/context-providers/keys.js +48 -0
  44. package/lib/context-providers/provider.d.ts +1 -0
  45. package/lib/context-providers/provider.js +6 -1
  46. package/lib/context-providers/security-groups.js +25 -2
  47. package/lib/context-providers/vpcs.js +19 -5
  48. package/lib/init-templates/v1/app/csharp/cdk.template.json +13 -1
  49. package/lib/init-templates/v1/app/fsharp/cdk.template.json +12 -1
  50. package/lib/init-templates/v1/app/go/%name%.template.go +6 -6
  51. package/lib/init-templates/v1/app/go/%name%_test.template.go +19 -21
  52. package/lib/init-templates/v1/app/go/cdk.template.json +12 -2
  53. package/lib/init-templates/v1/app/go/go.template.mod +0 -4
  54. package/lib/init-templates/v1/app/java/cdk.json +11 -1
  55. package/lib/init-templates/v1/app/java/pom.template.xml +6 -12
  56. package/lib/init-templates/v1/app/java/src/main/java/com/myorg/%name.PascalCased%Stack.template.java +7 -0
  57. package/lib/init-templates/v1/app/java/src/test/java/com/myorg/%name.PascalCased%Test.template.java +19 -21
  58. package/lib/init-templates/v1/app/javascript/cdk.template.json +13 -1
  59. package/lib/init-templates/v1/app/javascript/lib/%name%-stack.template.js +6 -0
  60. package/lib/init-templates/v1/app/javascript/package.template.json +1 -1
  61. package/lib/init-templates/v1/app/javascript/test/%name%.test.template.js +16 -11
  62. package/lib/init-templates/v1/app/python/%name.PythonModule%/%name.PythonModule%_stack.template.py +10 -1
  63. package/lib/init-templates/v1/app/python/cdk.template.json +13 -1
  64. package/lib/init-templates/v1/app/python/requirements-dev.txt +1 -0
  65. package/lib/init-templates/v1/app/python/requirements.template.txt +2 -0
  66. package/lib/init-templates/v1/app/python/tests/__init__.py +0 -0
  67. package/lib/init-templates/v1/app/python/tests/unit/__init__.py +0 -0
  68. package/lib/init-templates/v1/app/python/tests/unit/test_%name.PythonModule%_stack.template.py +19 -0
  69. package/lib/init-templates/v1/app/typescript/cdk.template.json +15 -1
  70. package/lib/init-templates/v1/app/typescript/lib/%name%-stack.template.ts +6 -0
  71. package/lib/init-templates/v1/app/typescript/package.template.json +1 -1
  72. package/lib/init-templates/v1/app/typescript/test/%name%.test.template.ts +15 -11
  73. package/lib/init-templates/v1/app/typescript/tsconfig.json +10 -3
  74. package/lib/init-templates/v1/lib/typescript/lib/index.template.ts +6 -0
  75. package/lib/init-templates/v1/lib/typescript/package.template.json +1 -1
  76. package/lib/init-templates/v1/lib/typescript/test/%name%.test.template.ts +16 -13
  77. package/lib/init-templates/v1/lib/typescript/tsconfig.json +12 -6
  78. package/lib/init-templates/v1/sample-app/csharp/README.template.md +3 -0
  79. package/lib/init-templates/v1/sample-app/csharp/cdk.template.json +13 -1
  80. package/lib/init-templates/v1/sample-app/fsharp/cdk.template.json +12 -1
  81. package/lib/init-templates/v1/sample-app/go/%name%.template.go +71 -0
  82. package/lib/init-templates/v1/sample-app/go/%name%_test.template.go +25 -0
  83. package/lib/init-templates/v1/sample-app/go/.template.gitignore +19 -0
  84. package/lib/init-templates/v1/sample-app/go/README.md +14 -0
  85. package/lib/init-templates/v1/sample-app/go/cdk.template.json +13 -0
  86. package/lib/init-templates/v1/sample-app/go/go.template.mod +9 -0
  87. package/lib/init-templates/v1/sample-app/java/README.template.md +4 -0
  88. package/lib/init-templates/v1/sample-app/java/cdk.json +11 -1
  89. package/lib/init-templates/v1/sample-app/java/pom.template.xml +6 -12
  90. package/lib/init-templates/v1/sample-app/java/src/test/java/com/myorg/%name.PascalCased%StackTest.template.java +9 -10
  91. package/lib/init-templates/v1/sample-app/javascript/README.template.md +3 -0
  92. package/lib/init-templates/v1/sample-app/javascript/cdk.template.json +13 -1
  93. package/lib/init-templates/v1/sample-app/javascript/package.template.json +1 -1
  94. package/lib/init-templates/v1/sample-app/javascript/test/%name%.test.template.js +13 -9
  95. package/lib/init-templates/v1/sample-app/javascript/tsconfig.json +14 -5
  96. package/lib/init-templates/v1/sample-app/python/README.template.md +3 -0
  97. package/lib/init-templates/v1/sample-app/python/cdk.template.json +13 -1
  98. package/lib/init-templates/v1/sample-app/python/requirements-dev.txt +1 -0
  99. package/lib/init-templates/v1/sample-app/python/requirements.template.txt +7 -0
  100. package/lib/init-templates/v1/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py +16 -11
  101. package/lib/init-templates/v1/sample-app/typescript/README.template.md +4 -0
  102. package/lib/init-templates/v1/sample-app/typescript/cdk.template.json +15 -1
  103. package/lib/init-templates/v1/sample-app/typescript/package.template.json +1 -1
  104. package/lib/init-templates/v1/sample-app/typescript/test/%name%.test.template.ts +11 -7
  105. package/lib/init-templates/v1/sample-app/typescript/tsconfig.json +12 -5
  106. package/lib/init-templates/v2/app/csharp/cdk.template.json +13 -1
  107. package/lib/init-templates/v2/app/fsharp/cdk.template.json +12 -1
  108. package/lib/init-templates/v2/app/go/%name%.template.go +6 -6
  109. package/lib/init-templates/v2/app/go/%name%_test.template.go +19 -21
  110. package/lib/init-templates/v2/app/go/cdk.template.json +12 -2
  111. package/lib/init-templates/v2/app/go/go.template.mod +0 -4
  112. package/lib/init-templates/v2/app/java/cdk.json +11 -1
  113. package/lib/init-templates/v2/app/java/pom.template.xml +1 -13
  114. package/lib/init-templates/v2/app/java/src/main/java/com/myorg/%name.PascalCased%Stack.template.java +7 -0
  115. package/lib/init-templates/v2/app/java/src/test/java/com/myorg/%name.PascalCased%Test.template.java +19 -21
  116. package/lib/init-templates/v2/app/javascript/cdk.template.json +13 -1
  117. package/lib/init-templates/v2/app/javascript/lib/%name%-stack.template.js +7 -1
  118. package/lib/init-templates/v2/app/javascript/test/%name%.test.template.js +15 -9
  119. package/lib/init-templates/v2/app/python/%name.PythonModule%/%name.PythonModule%_stack.template.py +11 -1
  120. package/lib/init-templates/v2/app/python/cdk.template.json +13 -1
  121. package/lib/init-templates/v2/app/python/requirements-dev.txt +1 -0
  122. package/lib/init-templates/v2/app/python/requirements.template.txt +2 -0
  123. package/lib/init-templates/v2/app/python/tests/__init__.py +0 -0
  124. package/lib/init-templates/v2/app/python/tests/unit/__init__.py +0 -0
  125. package/lib/init-templates/v2/app/python/tests/unit/test_%name.PythonModule%_stack.template.py +15 -0
  126. package/lib/init-templates/v2/app/typescript/cdk.template.json +15 -1
  127. package/lib/init-templates/v2/app/typescript/lib/%name%-stack.template.ts +6 -0
  128. package/lib/init-templates/v2/app/typescript/test/%name%.test.template.ts +15 -9
  129. package/lib/init-templates/v2/app/typescript/tsconfig.json +10 -3
  130. package/lib/init-templates/v2/lib/typescript/lib/index.template.ts +6 -0
  131. package/lib/init-templates/v2/lib/typescript/package.template.json +2 -4
  132. package/lib/init-templates/v2/lib/typescript/test/%name%.test.template.ts +16 -10
  133. package/lib/init-templates/v2/lib/typescript/tsconfig.json +12 -6
  134. package/lib/init-templates/v2/sample-app/csharp/cdk.template.json +13 -1
  135. package/lib/init-templates/v2/sample-app/fsharp/cdk.template.json +12 -1
  136. package/lib/init-templates/v2/sample-app/go/%name%.template.go +71 -0
  137. package/lib/init-templates/v2/sample-app/go/%name%_test.template.go +25 -0
  138. package/lib/init-templates/v2/sample-app/go/.template.gitignore +19 -0
  139. package/lib/init-templates/v2/sample-app/go/README.md +14 -0
  140. package/lib/init-templates/v2/sample-app/go/cdk.template.json +13 -0
  141. package/lib/init-templates/v2/sample-app/go/go.template.mod +9 -0
  142. package/lib/init-templates/v2/sample-app/java/cdk.json +11 -1
  143. package/lib/init-templates/v2/sample-app/java/pom.template.xml +1 -13
  144. package/lib/init-templates/v2/sample-app/java/src/test/java/com/myorg/%name.PascalCased%StackTest.template.java +10 -10
  145. package/lib/init-templates/v2/sample-app/javascript/cdk.template.json +13 -1
  146. package/lib/init-templates/v2/sample-app/javascript/test/%name%.test.template.js +11 -7
  147. package/lib/init-templates/v2/sample-app/javascript/tsconfig.json +14 -5
  148. package/lib/init-templates/v2/sample-app/python/cdk.template.json +13 -1
  149. package/lib/init-templates/v2/sample-app/python/requirements-dev.txt +1 -0
  150. package/lib/init-templates/v2/sample-app/python/requirements.template.txt +2 -0
  151. package/lib/init-templates/v2/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py +14 -12
  152. package/lib/init-templates/v2/sample-app/typescript/cdk.template.json +15 -1
  153. package/lib/init-templates/v2/sample-app/typescript/test/%name%.test.template.ts +12 -7
  154. package/lib/init-templates/v2/sample-app/typescript/tsconfig.json +12 -5
  155. package/lib/plugin.d.ts +20 -0
  156. package/lib/plugin.js +28 -1
  157. package/lib/settings.d.ts +10 -1
  158. package/lib/settings.js +17 -2
  159. package/lib/util/asset-publishing.js +26 -4
  160. package/lib/util/bool.d.ts +7 -0
  161. package/lib/util/bool.js +14 -0
  162. package/lib/util/index.d.ts +1 -0
  163. package/lib/util/index.js +2 -1
  164. package/npm-shrinkwrap.json +416 -279
  165. package/package.json +41 -40
  166. package/test/account-cache.test.js +4 -4
  167. package/test/api/cloud-assembly.test.js +43 -11
  168. package/test/api/cloud-executable.test.js +4 -4
  169. package/test/api/cloudformation-deployments.test.js +14 -1
  170. package/test/api/console-listener.d.ts +19 -0
  171. package/test/api/console-listener.js +47 -0
  172. package/test/api/deploy-stack.test.js +77 -1
  173. package/test/api/exec.test.js +30 -6
  174. package/test/api/fake-cloudformation-stack.d.ts +16 -0
  175. package/test/api/fake-cloudformation-stack.js +26 -0
  176. package/test/api/hotswap/ecs-services-hotswap-deployments.test.d.ts +1 -0
  177. package/test/api/hotswap/ecs-services-hotswap-deployments.test.js +331 -0
  178. package/test/api/hotswap/hotswap-deployments.test.d.ts +1 -0
  179. package/test/api/hotswap/hotswap-deployments.test.js +296 -0
  180. package/test/api/hotswap/hotswap-test-setup.d.ts +29 -0
  181. package/test/api/hotswap/hotswap-test-setup.js +91 -0
  182. package/test/api/hotswap/lambda-hotswap-deployments.test.d.ts +1 -0
  183. package/test/api/hotswap/lambda-hotswap-deployments.test.js +418 -0
  184. package/test/api/hotswap/s3-bucket-hotswap-deployments.test.d.ts +1 -0
  185. package/test/api/hotswap/s3-bucket-hotswap-deployments.test.js +678 -0
  186. package/test/api/hotswap/state-machine-hotswap-deployments.test.d.ts +1 -0
  187. package/test/api/hotswap/state-machine-hotswap-deployments.test.js +446 -0
  188. package/test/api/stack-activity-monitor.test.d.ts +1 -0
  189. package/test/api/stack-activity-monitor.test.js +201 -0
  190. package/test/aws-sdk-non-public-apis.test.d.ts +1 -0
  191. package/test/aws-sdk-non-public-apis.test.js +23 -0
  192. package/test/cdk-toolkit.test.js +240 -28
  193. package/test/context-providers/asymmetric-vpcs.test.js +260 -16
  194. package/test/context-providers/generic.test.js +67 -5
  195. package/test/context-providers/keys.test.d.ts +1 -0
  196. package/test/context-providers/keys.test.js +138 -0
  197. package/test/context-providers/security-groups.test.js +199 -1
  198. package/test/context-providers/vpcs.test.js +179 -5
  199. package/test/context.test.js +3 -5
  200. package/test/diff.test.js +9 -1
  201. package/test/init.test.js +7 -7
  202. package/test/integ/cli/app/app.js +70 -19
  203. package/test/integ/cli/app/nested-stack.js +11 -3
  204. package/test/integ/cli/bootstrapping.integtest.js +1 -15
  205. package/test/integ/cli/cli.integtest.js +147 -105
  206. package/test/integ/cli-regression-patches/v1.119.0/NOTES.md +5 -0
  207. package/test/integ/cli-regression-patches/v1.119.0/cli.integtest.js +659 -0
  208. package/test/integ/cli-regression-patches/v1.130.0/NOTES.md +12 -0
  209. package/test/integ/cli-regression-patches/v1.130.0/app/app.js +378 -0
  210. package/test/integ/cli-regression-patches/v1.130.0/bootstrapping.integtest.js +220 -0
  211. package/test/integ/helpers/aws.js +13 -4
  212. package/test/integ/helpers/cdk.d.ts +2 -0
  213. package/test/integ/helpers/cdk.js +62 -20
  214. package/test/integ/helpers/monorepo.js +2 -2
  215. package/test/integ/init/test-go.sh +5 -1
  216. package/test/integ/init/test-java.sh +1 -0
  217. package/test/integ/init/test-python.sh +2 -0
  218. package/test/integ/run-against-dist +5 -0
  219. package/test/integ/run-against-dist.bash +2 -0
  220. package/test/integ/run-against-release +8 -1
  221. package/test/integ/run-wrappers/dist/pip_ +9 -4
  222. package/test/integ/test-cli-regression.bash +8 -2
  223. package/test/settings.test.js +28 -1
  224. package/test/usersettings.test.js +18 -1
  225. package/test/util/cloudformation.test.js +22 -3
  226. package/test/util/mock-child_process.d.ts +1 -5
  227. package/test/util/mock-child_process.js +5 -12
  228. package/test/util/mock-sdk.d.ts +20 -0
  229. package/test/util/mock-sdk.js +34 -2
  230. package/test/util.js +1 -1
  231. package/lib/init-templates/v1/app/python/requirements.txt +0 -1
  232. package/lib/init-templates/v1/app/python/setup.template.py +0 -43
  233. package/lib/init-templates/v1/sample-app/python/requirements.txt +0 -2
  234. package/lib/init-templates/v1/sample-app/python/setup.template.py +0 -48
  235. package/lib/init-templates/v2/app/python/requirements.txt +0 -1
  236. package/lib/init-templates/v2/app/python/setup.template.py +0 -44
  237. package/lib/init-templates/v2/sample-app/python/requirements.txt +0 -2
  238. package/lib/init-templates/v2/sample-app/python/setup.template.py +0 -44
package/README.md CHANGED
@@ -140,7 +140,7 @@ $ cdk diff --app='node bin/main.js' MyStackName --template=path/to/template.yml
140
140
 
141
141
  ### `cdk deploy`
142
142
 
143
- Deploys a stack of your CDK app to it's environment. During the deployment, the toolkit will output progress
143
+ Deploys a stack of your CDK app to its environment. During the deployment, the toolkit will output progress
144
144
  indications, similar to what can be observed in the AWS CloudFormation Console. If the environment was never
145
145
  bootstrapped (using `cdk bootstrap`), only stacks that are not using assets and synthesize to a template that is under
146
146
  51,200 bytes will successfully deploy.
@@ -154,6 +154,24 @@ currently deployed stack to the template and tags that are about to be deployed
154
154
  will skip deployment if they are identical. Use `--force` to override this behavior
155
155
  and always deploy the stack.
156
156
 
157
+ #### Disabling Rollback
158
+
159
+ If a resource fails to be created or updated, the deployment will *roll back* before the CLI returns. All changes made
160
+ up to that point will be undone (resources that were created will be deleted, updates that were made will be changed
161
+ back) in order to leave the stack in a consistent state at the end of the operation. If you are using the CDK CLI
162
+ to iterate on a development stack in your personal account, you might not require CloudFormation to leave your
163
+ stack in a consistent state, but instead would prefer to update your CDK application and try again.
164
+
165
+ To disable the rollback feature, specify `--no-rollback` (`-R` for short):
166
+
167
+ ```console
168
+ $ cdk deploy --no-rollback
169
+ $ cdk deploy -R
170
+ ```
171
+
172
+ NOTE: you cannot use `--no-rollback` for any updates that would cause a resource replacement, only for updates
173
+ and creations of new resources.
174
+
157
175
  #### Deploying multiple stacks
158
176
 
159
177
  You can have multiple stacks in a cdk app. An example can be found in [how to create multiple stacks](https://docs.aws.amazon.com/cdk/latest/guide/stack_how_to_create_multiple_stacks.html).
@@ -221,6 +239,24 @@ Specify an outputs file to write to by supplying the `--outputs-file` parameter
221
239
  $ cdk deploy --outputs-file outputs.json
222
240
  ```
223
241
 
242
+ Alternatively, the `outputsFile` key can be specified in the project config (`cdk.json`).
243
+
244
+ The following shows a sample `cdk.json` where the `outputsFile` key is set to *outputs.json*.
245
+
246
+ ```json
247
+ {
248
+ "app": "npx ts-node bin/myproject.ts",
249
+ "context": {
250
+ "@aws-cdk/core:enableStackNameDuplicates": "true",
251
+ "aws-cdk:enableDiffNoFail": "true",
252
+ "@aws-cdk/core:stackRelativeExports": "true"
253
+ },
254
+ "outputsFile": "outputs.json"
255
+ }
256
+ ```
257
+
258
+ The `outputsFile` key can also be specified as a user setting (`~/.cdk.json`)
259
+
224
260
  When the stack finishes deployment, `outputs.json` would look like this:
225
261
 
226
262
  ```json
@@ -291,13 +327,115 @@ For more control over when stack changes are deployed, the CDK can generate a
291
327
  CloudFormation change set but not execute it. The default name of the generated
292
328
  change set is *cdk-deploy-change-set*, and a previous change set with that
293
329
  name will be overwritten. The change set will always be created, even if it
294
- is empty. A name can also be given to the change set to make it easier to later
330
+ is empty. A name can also be given to the change set to make it easier to later
295
331
  execute.
296
332
 
297
333
  ```console
298
334
  $ cdk deploy --no-execute --change-set-name MyChangeSetName
299
335
  ```
300
336
 
337
+ #### Hotswap deployments for faster development
338
+
339
+ You can pass the `--hotswap` flag to the `deploy` command:
340
+
341
+ ```console
342
+ $ cdk deploy --hotswap [StackNames]
343
+ ```
344
+
345
+ This will attempt to perform a faster, short-circuit deployment if possible
346
+ (for example, if you only changed the code of a Lambda function in your CDK app,
347
+ but nothing else in your CDK code),
348
+ skipping CloudFormation, and updating the affected resources directly.
349
+ If the tool detects that the change does not support hotswapping,
350
+ it will fall back and perform a full CloudFormation deployment,
351
+ exactly like `cdk deploy` does without the `--hotswap` flag.
352
+
353
+ Passing this option to `cdk deploy` will make it use your current AWS credentials to perform the API calls -
354
+ it will not assume the Roles from your bootstrap stack,
355
+ even if the `@aws-cdk/core:newStyleStackSynthesis` feature flag is set to `true`
356
+ (as those Roles do not have the necessary permissions to update AWS resources directly, without using CloudFormation).
357
+ For that reason, make sure that your credentials are for the same AWS account that the Stack(s)
358
+ you are performing the hotswap deployment for belong to,
359
+ and that you have the necessary IAM permissions to update the resources that are being deployed.
360
+
361
+ Hotswapping is currently supported for the following changes
362
+ (additional changes will be supported in the future):
363
+
364
+ - Code asset changes of AWS Lambda functions.
365
+ - Definition changes of AWS Step Functions State Machines.
366
+ - Container asset changes of AWS ECS Services.
367
+ - Website asset changes of AWS S3 Bucket Deployments.
368
+
369
+ **⚠ Note #1**: This command deliberately introduces drift in CloudFormation stacks in order to speed up deployments.
370
+ For this reason, only use it for development purposes.
371
+ **Never use this flag for your production deployments**!
372
+
373
+ **⚠ Note #2**: This command is considered experimental,
374
+ and might have breaking changes in the future.
375
+
376
+ ### `cdk watch`
377
+
378
+ The `watch` command is similar to `deploy`,
379
+ but instead of being a one-shot operation,
380
+ the command continuously monitors the files of the project,
381
+ and triggers a deployment whenever it detects any changes:
382
+
383
+ ```console
384
+ $ cdk watch DevelopmentStack
385
+ Detected change to 'lambda-code/index.js' (type: change). Triggering 'cdk deploy'
386
+ DevelopmentStack: deploying...
387
+
388
+ ✅ DevelopmentStack
389
+
390
+ ^C
391
+ ```
392
+
393
+ To end a `cdk watch` session, interrupt the process by pressing Ctrl+C.
394
+
395
+ What files are observed is determined by the `"watch"` setting in your `cdk.json` file.
396
+ It has two sub-keys, `"include"` and `"exclude"`, each of which can be either a single string, or an array of strings.
397
+ Each entry is interpreted as a path relative to the location of the `cdk.json` file.
398
+ Globs, both `*` and `**`, are allowed to be used.
399
+ Example:
400
+
401
+ ```json
402
+ {
403
+ "app": "mvn -e -q compile exec:java",
404
+ "watch": {
405
+ "include": "src/main/**",
406
+ "exclude": "target/*"
407
+ }
408
+ }
409
+ ```
410
+
411
+ The default for `"include"` is `"**/*"`
412
+ (which means all files and directories in the root of the project),
413
+ and `"exclude"` is optional
414
+ (note that we always ignore files and directories starting with `.`,
415
+ the CDK output directory, and the `node_modules` directory),
416
+ so the minimal settings to enable `watch` are `"watch": {}`.
417
+
418
+ If either your CDK code, or application code, needs a build step before being deployed,
419
+ `watch` works with the `"build"` key in the `cdk.json` file,
420
+ for example:
421
+
422
+ ```json
423
+ {
424
+ "app": "mvn -e -q exec:java",
425
+ "build": "mvn package",
426
+ "watch": {
427
+ "include": "src/main/**",
428
+ "exclude": "target/*"
429
+ }
430
+ }
431
+ ```
432
+
433
+ Note that `watch` by default uses hotswap deployments (see above for details) --
434
+ to turn them off, pass the `--no-hotswap` option when invoking it.
435
+
436
+ **Note**: This command is considered experimental,
437
+ and might have breaking changes in the future.
438
+
301
439
  ### `cdk destroy`
302
440
 
303
441
  Deletes a stack from it's environment. This will cause the resources in the stack to be destroyed (unless they were
@@ -390,6 +528,7 @@ Some of the interesting keys that can be used in the JSON configuration files:
390
528
  ```json5
391
529
  {
392
530
  "app": "node bin/main.js", // Command to start the CDK app (--app='node bin/main.js')
531
+ "build": "mvn package", // Specify pre-synth build (no command line option)
393
532
  "context": { // Context entries (--context=key=value)
394
533
  "key": "value"
395
534
  },
@@ -399,6 +538,12 @@ Some of the interesting keys that can be used in the JSON configuration files:
399
538
  }
400
539
  ```
401
540
 
541
+ If specified, the command in the `build` key will be executed immediately before synthesis.
542
+ This can be used to build Lambda Functions, CDK Application code, or other assets.
543
+ `build` cannot be specified on the command line or in the User configuration,
544
+ and must be specified in the Project configuration. The command specified
545
+ in `build` will be executed by the "watch" process before deployment.
546
+
402
547
  ### Environment
403
548
 
404
549
  The following environment variables affect aws-cdk:
package/bin/cdk.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import 'source-map-support/register';
3
+ import '@jsii/check-node/run';