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.
- package/README.md +147 -2
- package/bin/cdk.d.ts +1 -0
- package/bin/cdk.js +109 -14
- package/build-info.json +2 -2
- package/lib/api/aws-auth/awscli-compatible.js +14 -7
- package/lib/api/aws-auth/sdk-provider.js +17 -24
- package/lib/api/aws-auth/sdk.d.ts +23 -0
- package/lib/api/aws-auth/sdk.js +43 -1
- package/lib/api/bootstrap/bootstrap-template.yaml +59 -26
- package/lib/api/bootstrap/deploy-bootstrap.js +2 -2
- package/lib/api/cloudformation-deployments.d.ts +17 -4
- package/lib/api/cloudformation-deployments.js +27 -22
- package/lib/api/cxapp/cloud-assembly.d.ts +19 -1
- package/lib/api/cxapp/cloud-assembly.js +79 -49
- package/lib/api/cxapp/cloud-executable.d.ts +6 -2
- package/lib/api/cxapp/cloud-executable.js +8 -4
- package/lib/api/cxapp/exec.js +8 -4
- package/lib/api/deploy-stack.d.ts +13 -0
- package/lib/api/deploy-stack.js +56 -25
- package/lib/api/hotswap/common.d.ts +55 -0
- package/lib/api/hotswap/common.js +53 -0
- package/lib/api/hotswap/ecs-services.d.ts +3 -0
- package/lib/api/hotswap/ecs-services.js +174 -0
- package/lib/api/hotswap/evaluate-cloudformation-template.d.ts +44 -0
- package/lib/api/hotswap/evaluate-cloudformation-template.js +247 -0
- package/lib/api/hotswap/lambda-functions.d.ts +9 -0
- package/lib/api/hotswap/lambda-functions.js +102 -0
- package/lib/api/hotswap/s3-bucket-deployments.d.ts +8 -0
- package/lib/api/hotswap/s3-bucket-deployments.js +113 -0
- package/lib/api/hotswap/stepfunctions-state-machines.d.ts +3 -0
- package/lib/api/hotswap/stepfunctions-state-machines.js +54 -0
- package/lib/api/hotswap-deployments.d.ts +21 -0
- package/lib/api/hotswap-deployments.js +161 -0
- package/lib/api/util/cloudformation/stack-activity-monitor.d.ts +1 -0
- package/lib/api/util/cloudformation/stack-activity-monitor.js +25 -6
- package/lib/api/util/cloudformation.d.ts +3 -1
- package/lib/api/util/cloudformation.js +6 -4
- package/lib/cdk-toolkit.d.ts +79 -28
- package/lib/cdk-toolkit.js +160 -28
- package/lib/context-providers/index.d.ts +10 -5
- package/lib/context-providers/index.js +38 -17
- package/lib/context-providers/keys.d.ts +11 -0
- package/lib/context-providers/keys.js +48 -0
- package/lib/context-providers/provider.d.ts +1 -0
- package/lib/context-providers/provider.js +6 -1
- package/lib/context-providers/security-groups.js +25 -2
- package/lib/context-providers/vpcs.js +19 -5
- package/lib/init-templates/v1/app/csharp/cdk.template.json +13 -1
- package/lib/init-templates/v1/app/fsharp/cdk.template.json +12 -1
- package/lib/init-templates/v1/app/go/%name%.template.go +6 -6
- package/lib/init-templates/v1/app/go/%name%_test.template.go +19 -21
- package/lib/init-templates/v1/app/go/cdk.template.json +12 -2
- package/lib/init-templates/v1/app/go/go.template.mod +0 -4
- package/lib/init-templates/v1/app/java/cdk.json +11 -1
- package/lib/init-templates/v1/app/java/pom.template.xml +6 -12
- package/lib/init-templates/v1/app/java/src/main/java/com/myorg/%name.PascalCased%Stack.template.java +7 -0
- package/lib/init-templates/v1/app/java/src/test/java/com/myorg/%name.PascalCased%Test.template.java +19 -21
- package/lib/init-templates/v1/app/javascript/cdk.template.json +13 -1
- package/lib/init-templates/v1/app/javascript/lib/%name%-stack.template.js +6 -0
- package/lib/init-templates/v1/app/javascript/package.template.json +1 -1
- package/lib/init-templates/v1/app/javascript/test/%name%.test.template.js +16 -11
- package/lib/init-templates/v1/app/python/%name.PythonModule%/%name.PythonModule%_stack.template.py +10 -1
- package/lib/init-templates/v1/app/python/cdk.template.json +13 -1
- package/lib/init-templates/v1/app/python/requirements-dev.txt +1 -0
- package/lib/init-templates/v1/app/python/requirements.template.txt +2 -0
- package/lib/init-templates/v1/app/python/tests/__init__.py +0 -0
- package/lib/init-templates/v1/app/python/tests/unit/__init__.py +0 -0
- package/lib/init-templates/v1/app/python/tests/unit/test_%name.PythonModule%_stack.template.py +19 -0
- package/lib/init-templates/v1/app/typescript/cdk.template.json +15 -1
- package/lib/init-templates/v1/app/typescript/lib/%name%-stack.template.ts +6 -0
- package/lib/init-templates/v1/app/typescript/package.template.json +1 -1
- package/lib/init-templates/v1/app/typescript/test/%name%.test.template.ts +15 -11
- package/lib/init-templates/v1/app/typescript/tsconfig.json +10 -3
- package/lib/init-templates/v1/lib/typescript/lib/index.template.ts +6 -0
- package/lib/init-templates/v1/lib/typescript/package.template.json +1 -1
- package/lib/init-templates/v1/lib/typescript/test/%name%.test.template.ts +16 -13
- package/lib/init-templates/v1/lib/typescript/tsconfig.json +12 -6
- package/lib/init-templates/v1/sample-app/csharp/README.template.md +3 -0
- package/lib/init-templates/v1/sample-app/csharp/cdk.template.json +13 -1
- package/lib/init-templates/v1/sample-app/fsharp/cdk.template.json +12 -1
- package/lib/init-templates/v1/sample-app/go/%name%.template.go +71 -0
- package/lib/init-templates/v1/sample-app/go/%name%_test.template.go +25 -0
- package/lib/init-templates/v1/sample-app/go/.template.gitignore +19 -0
- package/lib/init-templates/v1/sample-app/go/README.md +14 -0
- package/lib/init-templates/v1/sample-app/go/cdk.template.json +13 -0
- package/lib/init-templates/v1/sample-app/go/go.template.mod +9 -0
- package/lib/init-templates/v1/sample-app/java/README.template.md +4 -0
- package/lib/init-templates/v1/sample-app/java/cdk.json +11 -1
- package/lib/init-templates/v1/sample-app/java/pom.template.xml +6 -12
- package/lib/init-templates/v1/sample-app/java/src/test/java/com/myorg/%name.PascalCased%StackTest.template.java +9 -10
- package/lib/init-templates/v1/sample-app/javascript/README.template.md +3 -0
- package/lib/init-templates/v1/sample-app/javascript/cdk.template.json +13 -1
- package/lib/init-templates/v1/sample-app/javascript/package.template.json +1 -1
- package/lib/init-templates/v1/sample-app/javascript/test/%name%.test.template.js +13 -9
- package/lib/init-templates/v1/sample-app/javascript/tsconfig.json +14 -5
- package/lib/init-templates/v1/sample-app/python/README.template.md +3 -0
- package/lib/init-templates/v1/sample-app/python/cdk.template.json +13 -1
- package/lib/init-templates/v1/sample-app/python/requirements-dev.txt +1 -0
- package/lib/init-templates/v1/sample-app/python/requirements.template.txt +7 -0
- package/lib/init-templates/v1/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py +16 -11
- package/lib/init-templates/v1/sample-app/typescript/README.template.md +4 -0
- package/lib/init-templates/v1/sample-app/typescript/cdk.template.json +15 -1
- package/lib/init-templates/v1/sample-app/typescript/package.template.json +1 -1
- package/lib/init-templates/v1/sample-app/typescript/test/%name%.test.template.ts +11 -7
- package/lib/init-templates/v1/sample-app/typescript/tsconfig.json +12 -5
- package/lib/init-templates/v2/app/csharp/cdk.template.json +13 -1
- package/lib/init-templates/v2/app/fsharp/cdk.template.json +12 -1
- package/lib/init-templates/v2/app/go/%name%.template.go +6 -6
- package/lib/init-templates/v2/app/go/%name%_test.template.go +19 -21
- package/lib/init-templates/v2/app/go/cdk.template.json +12 -2
- package/lib/init-templates/v2/app/go/go.template.mod +0 -4
- package/lib/init-templates/v2/app/java/cdk.json +11 -1
- package/lib/init-templates/v2/app/java/pom.template.xml +1 -13
- package/lib/init-templates/v2/app/java/src/main/java/com/myorg/%name.PascalCased%Stack.template.java +7 -0
- package/lib/init-templates/v2/app/java/src/test/java/com/myorg/%name.PascalCased%Test.template.java +19 -21
- package/lib/init-templates/v2/app/javascript/cdk.template.json +13 -1
- package/lib/init-templates/v2/app/javascript/lib/%name%-stack.template.js +7 -1
- package/lib/init-templates/v2/app/javascript/test/%name%.test.template.js +15 -9
- package/lib/init-templates/v2/app/python/%name.PythonModule%/%name.PythonModule%_stack.template.py +11 -1
- package/lib/init-templates/v2/app/python/cdk.template.json +13 -1
- package/lib/init-templates/v2/app/python/requirements-dev.txt +1 -0
- package/lib/init-templates/v2/app/python/requirements.template.txt +2 -0
- package/lib/init-templates/v2/app/python/tests/__init__.py +0 -0
- package/lib/init-templates/v2/app/python/tests/unit/__init__.py +0 -0
- package/lib/init-templates/v2/app/python/tests/unit/test_%name.PythonModule%_stack.template.py +15 -0
- package/lib/init-templates/v2/app/typescript/cdk.template.json +15 -1
- package/lib/init-templates/v2/app/typescript/lib/%name%-stack.template.ts +6 -0
- package/lib/init-templates/v2/app/typescript/test/%name%.test.template.ts +15 -9
- package/lib/init-templates/v2/app/typescript/tsconfig.json +10 -3
- package/lib/init-templates/v2/lib/typescript/lib/index.template.ts +6 -0
- package/lib/init-templates/v2/lib/typescript/package.template.json +2 -4
- package/lib/init-templates/v2/lib/typescript/test/%name%.test.template.ts +16 -10
- package/lib/init-templates/v2/lib/typescript/tsconfig.json +12 -6
- package/lib/init-templates/v2/sample-app/csharp/cdk.template.json +13 -1
- package/lib/init-templates/v2/sample-app/fsharp/cdk.template.json +12 -1
- package/lib/init-templates/v2/sample-app/go/%name%.template.go +71 -0
- package/lib/init-templates/v2/sample-app/go/%name%_test.template.go +25 -0
- package/lib/init-templates/v2/sample-app/go/.template.gitignore +19 -0
- package/lib/init-templates/v2/sample-app/go/README.md +14 -0
- package/lib/init-templates/v2/sample-app/go/cdk.template.json +13 -0
- package/lib/init-templates/v2/sample-app/go/go.template.mod +9 -0
- package/lib/init-templates/v2/sample-app/java/cdk.json +11 -1
- package/lib/init-templates/v2/sample-app/java/pom.template.xml +1 -13
- package/lib/init-templates/v2/sample-app/java/src/test/java/com/myorg/%name.PascalCased%StackTest.template.java +10 -10
- package/lib/init-templates/v2/sample-app/javascript/cdk.template.json +13 -1
- package/lib/init-templates/v2/sample-app/javascript/test/%name%.test.template.js +11 -7
- package/lib/init-templates/v2/sample-app/javascript/tsconfig.json +14 -5
- package/lib/init-templates/v2/sample-app/python/cdk.template.json +13 -1
- package/lib/init-templates/v2/sample-app/python/requirements-dev.txt +1 -0
- package/lib/init-templates/v2/sample-app/python/requirements.template.txt +2 -0
- package/lib/init-templates/v2/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py +14 -12
- package/lib/init-templates/v2/sample-app/typescript/cdk.template.json +15 -1
- package/lib/init-templates/v2/sample-app/typescript/test/%name%.test.template.ts +12 -7
- package/lib/init-templates/v2/sample-app/typescript/tsconfig.json +12 -5
- package/lib/plugin.d.ts +20 -0
- package/lib/plugin.js +28 -1
- package/lib/settings.d.ts +10 -1
- package/lib/settings.js +17 -2
- package/lib/util/asset-publishing.js +26 -4
- package/lib/util/bool.d.ts +7 -0
- package/lib/util/bool.js +14 -0
- package/lib/util/index.d.ts +1 -0
- package/lib/util/index.js +2 -1
- package/npm-shrinkwrap.json +416 -279
- package/package.json +41 -40
- package/test/account-cache.test.js +4 -4
- package/test/api/cloud-assembly.test.js +43 -11
- package/test/api/cloud-executable.test.js +4 -4
- package/test/api/cloudformation-deployments.test.js +14 -1
- package/test/api/console-listener.d.ts +19 -0
- package/test/api/console-listener.js +47 -0
- package/test/api/deploy-stack.test.js +77 -1
- package/test/api/exec.test.js +30 -6
- package/test/api/fake-cloudformation-stack.d.ts +16 -0
- package/test/api/fake-cloudformation-stack.js +26 -0
- package/test/api/hotswap/ecs-services-hotswap-deployments.test.d.ts +1 -0
- package/test/api/hotswap/ecs-services-hotswap-deployments.test.js +331 -0
- package/test/api/hotswap/hotswap-deployments.test.d.ts +1 -0
- package/test/api/hotswap/hotswap-deployments.test.js +296 -0
- package/test/api/hotswap/hotswap-test-setup.d.ts +29 -0
- package/test/api/hotswap/hotswap-test-setup.js +91 -0
- package/test/api/hotswap/lambda-hotswap-deployments.test.d.ts +1 -0
- package/test/api/hotswap/lambda-hotswap-deployments.test.js +418 -0
- package/test/api/hotswap/s3-bucket-hotswap-deployments.test.d.ts +1 -0
- package/test/api/hotswap/s3-bucket-hotswap-deployments.test.js +678 -0
- package/test/api/hotswap/state-machine-hotswap-deployments.test.d.ts +1 -0
- package/test/api/hotswap/state-machine-hotswap-deployments.test.js +446 -0
- package/test/api/stack-activity-monitor.test.d.ts +1 -0
- package/test/api/stack-activity-monitor.test.js +201 -0
- package/test/aws-sdk-non-public-apis.test.d.ts +1 -0
- package/test/aws-sdk-non-public-apis.test.js +23 -0
- package/test/cdk-toolkit.test.js +240 -28
- package/test/context-providers/asymmetric-vpcs.test.js +260 -16
- package/test/context-providers/generic.test.js +67 -5
- package/test/context-providers/keys.test.d.ts +1 -0
- package/test/context-providers/keys.test.js +138 -0
- package/test/context-providers/security-groups.test.js +199 -1
- package/test/context-providers/vpcs.test.js +179 -5
- package/test/context.test.js +3 -5
- package/test/diff.test.js +9 -1
- package/test/init.test.js +7 -7
- package/test/integ/cli/app/app.js +70 -19
- package/test/integ/cli/app/nested-stack.js +11 -3
- package/test/integ/cli/bootstrapping.integtest.js +1 -15
- package/test/integ/cli/cli.integtest.js +147 -105
- package/test/integ/cli-regression-patches/v1.119.0/NOTES.md +5 -0
- package/test/integ/cli-regression-patches/v1.119.0/cli.integtest.js +659 -0
- package/test/integ/cli-regression-patches/v1.130.0/NOTES.md +12 -0
- package/test/integ/cli-regression-patches/v1.130.0/app/app.js +378 -0
- package/test/integ/cli-regression-patches/v1.130.0/bootstrapping.integtest.js +220 -0
- package/test/integ/helpers/aws.js +13 -4
- package/test/integ/helpers/cdk.d.ts +2 -0
- package/test/integ/helpers/cdk.js +62 -20
- package/test/integ/helpers/monorepo.js +2 -2
- package/test/integ/init/test-go.sh +5 -1
- package/test/integ/init/test-java.sh +1 -0
- package/test/integ/init/test-python.sh +2 -0
- package/test/integ/run-against-dist +5 -0
- package/test/integ/run-against-dist.bash +2 -0
- package/test/integ/run-against-release +8 -1
- package/test/integ/run-wrappers/dist/pip_ +9 -4
- package/test/integ/test-cli-regression.bash +8 -2
- package/test/settings.test.js +28 -1
- package/test/usersettings.test.js +18 -1
- package/test/util/cloudformation.test.js +22 -3
- package/test/util/mock-child_process.d.ts +1 -5
- package/test/util/mock-child_process.js +5 -12
- package/test/util/mock-sdk.d.ts +20 -0
- package/test/util/mock-sdk.js +34 -2
- package/test/util.js +1 -1
- package/lib/init-templates/v1/app/python/requirements.txt +0 -1
- package/lib/init-templates/v1/app/python/setup.template.py +0 -43
- package/lib/init-templates/v1/sample-app/python/requirements.txt +0 -2
- package/lib/init-templates/v1/sample-app/python/setup.template.py +0 -48
- package/lib/init-templates/v2/app/python/requirements.txt +0 -1
- package/lib/init-templates/v2/app/python/setup.template.py +0 -44
- package/lib/init-templates/v2/sample-app/python/requirements.txt +0 -2
- 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
|
|
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