CLI Reference¶
The cdkx CLI has four commands. All commands read a cdkx.json configuration file from the current directory by default.
Global options¶
| Option | Description |
|---|---|
-V, --version |
Print the installed version |
-h, --help |
Show help for any command |
cdkx init¶
Scaffold a new cdkx project. Detects the environment (empty directory, existing Node project, or Nx workspace) and generates the appropriate files.
What it does:
- Creates
cdkx.json,src/main.ts,tsconfig.json, andpackage.json - Merges
package.jsonnon-destructively when an existing project is detected - Adds
synth,deploy,destroyscripts topackage.json - Runs the detected package manager's
installautomatically
Arguments:
| Argument | Description |
|---|---|
[directory] |
Target directory. Defaults to the current directory. |
Options:
| Option | Default | Description |
|---|---|---|
--name <name> |
directory basename | Project name written into package.json |
--mode <mode> |
auto-detected | Force empty, existing, or nx mode |
--package-manager <pm> |
auto-detected | Force yarn, npm, or pnpm |
--force |
false |
Overwrite existing src/main.ts and tsconfig.json |
--no-install |
— | Skip the automatic package install step |
Examples:
Output:
✔ Created /my-project/tsconfig.json
✔ Created /my-project/src/main.ts
✔ Created /my-project/package.json
✔ Created /my-project/cdkx.json
Running yarn install...
✔ Done. Run 'cdkx synth' to get started.
cdkx synth¶
Runs your app and synthesizes the cloud assembly into the output directory.
What it does:
- Reads
cdkx.jsonto find your app command - Runs the app with
CDKX_OUT_DIRinjected into the environment - Writes
manifest.jsonand one<StackId>.jsonper stack to the output directory
Options:
| Option | Default | Description |
|---|---|---|
-c, --config <file> |
cdkx.json |
Path to the config file |
-o, --output <dir> |
value from cdkx.json, or cdkx.out |
Override the output directory |
Examples:
Output:
cdkx deploy¶
Reads the synthesized cloud assembly and deploys all stacks to the target provider.
What it does:
- Reads the cloud assembly from the output directory
- Resolves cross-resource references (
{ ref, attr }tokens) - Builds a dependency graph and deploys resources in topological order
- Prints a live event table to the console
Options:
| Option | Default | Description |
|---|---|---|
-c, --config <file> |
cdkx.json |
Path to the config file |
-o, --output <dir> |
value from cdkx.json, or cdkx.out |
Override the assembly directory |
Examples:
Output:
MyStack Hetzner::Networking::Network NetworkA1B2C3D4 CREATE_IN_PROGRESS
MyStack Hetzner::Networking::Network NetworkA1B2C3D4 CREATED
MyStack Hetzner::Networking::Subnet SubnetE5F6G7H8 CREATE_IN_PROGRESS
MyStack Hetzner::Networking::Subnet SubnetE5F6G7H8 CREATED
State file
cdkx writes deployment state to .cdkx/ next to cdkx.json. Add .cdkx/ to your .gitignore if you do not want to commit it.
cdkx destroy¶
Destroys all resources in the cloud assembly in reverse dependency order.
What it does:
- Reads the cloud assembly from the output directory
- Prompts for confirmation (unless
--forceis set) - Deletes resources in reverse topological order
- Waits for each deletion action to complete before proceeding
Options:
| Option | Default | Description |
|---|---|---|
-c, --config <file> |
cdkx.json |
Path to the config file |
-o, --output <dir> |
value from cdkx.json, or cdkx.out |
Override the assembly directory |
--force |
false |
Skip the confirmation prompt |
Examples:
Output:
MyStack Hetzner::Networking::Subnet SubnetE5F6G7H8 DELETE_IN_PROGRESS
MyStack Hetzner::Networking::Subnet SubnetE5F6G7H8 DELETE_COMPLETE
MyStack Hetzner::Networking::Network NetworkA1B2C3D4 DELETE_IN_PROGRESS
MyStack Hetzner::Networking::Network NetworkA1B2C3D4 DELETE_COMPLETE
✔ All resources destroyed
Irreversible
Destroy permanently deletes cloud resources. Use --force only in environments where you are certain about the target.
cdkx.json reference¶
| Field | Type | Required | Description |
|---|---|---|---|
app |
string |
Yes | Command to run your app (e.g. npx ts-node my-app.ts) |
output |
string |
No | Output directory for the cloud assembly. Default: cdkx.out |