Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add settings for the "cdk watch" command #383

Merged
merged 3 commits into from
Oct 26, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 51 additions & 13 deletions text/0001-cdk-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,58 @@ Checking stack DataStack for possible hotswap update
Watching stack inputs for changes:
* LambdaFunction[Appfunction]: <spinner>
* LambdaFunction[StreamFunction]: <spinner>

```

The watcher can only watch for file changes. For Lambda code, that means that
directories will be watched for changes and zipped if they change. If the file
asset is a zip file, then the update will fire whenever that changes. The
existing docker asset builder will be used to watch for changes in local docker
images.
The "watch" functionality can be customized by setting a few new options in your `cdk.json` file:

1. If either your CDK code, or your runtime code
(like the code of your Lambda functions)
needs to go through a build step before invoking `cdk deploy`,
you can specify that command in the new `"build"` key. Example:

```json
{
"app": "mvn exec:java",
"build": "mvn package"
}
```

If the `"build"` key is present in the `cdk.json` file,
the "watch" process will invoke the specified command before performing synthesis.
skinny85 marked this conversation as resolved.
Show resolved Hide resolved
If your build process is more complex than just a single command,
`"build"` also accepts an array of commands:
skinny85 marked this conversation as resolved.
Show resolved Hide resolved

```json
{
"app": "node bin/app.js",
"build": [
"yarn --cwd src/lambda-code build",
"yarn build"
]
}
```

The commands will be executed one after the other,
in the same order as they were declared in the `cdk.json` file.

2. The "watch" process needs to know which files and directories to observe for changes,
and which ones to ignore. You can customize these using the `"include"` and `"exclude"`
sub-keys of the new `"watch"` top-level key:
skinny85 marked this conversation as resolved.
Show resolved Hide resolved

```json
{
"app": "mvn exec:java",
"build": "mvn package",
"watch": {
"include": ["src", "lambda/code/**/*"],
"exclude": ["cdk.out", "target"]
skinny85 marked this conversation as resolved.
Show resolved Hide resolved
}
}
```

The `cdk init` command fills these out for you,
so if your project has a standard layout,
you shouldn't need to modify these from the generated defaults.
skinny85 marked this conversation as resolved.
Show resolved Hide resolved

In addition to the monitoring mode, it is possible to perform one-shot
hotswap deployments on some or all of the stacks in the CDK application:
Expand Down Expand Up @@ -123,18 +167,12 @@ Deploying DataStack
Done!
```

In addition to running in a one shot mode, the `cdk deploy --hotswap`
command also has a `--watch` command line option that enable it to monitor the
assets on disk and perform an update when they change.

#### Resource Support

- AWS Lambda `Function`
- file and directory assets
- StepFunction
- Workflow definitions
- AWS Fargate
skinny85 marked this conversation as resolved.
Show resolved Hide resolved
- image assets
- State Machine definitions
- ECS
- image assets

Expand Down