Output streams
Five cdkd commands always write a machine-readable document to stdout and
send everything else to stderr, so you can pipe or redirect their output
without a flag. This page lists those commands, the ones that behave this way
only under --json, and the ones whose stdout is for reading.
cdkd synth MyStack > template.yaml 2> progress.log
cdkd synth MyStack | yq '.Resources | keys'
cdkd list --long --json | jq -r '.[].name'
cdkd state list | while read -r ref; do echo "state for: $ref"; done
cdkd local invoke MyStack/Handler --event event.json | jq .body
Commands whose stdout is always the document
On these five commands, stdout carries the document and nothing else:
| Command | What stdout carries |
|---|---|
cdkd synth |
The selected stack's CloudFormation template, or nothing. See cdkd synth. |
cdkd list |
The stack listing: one id per line, YAML under --long / --show-dependencies, JSON under --json. |
cdkd state list |
The state records: one Stack (region) per line, JSON under --json. |
cdkd local invoke |
The function's response payload. |
cdkd local invoke-agentcore |
The agent's response, buffered or streamed frame by frame. |
Everything that is not the document goes to stderr. That includes progress
lines such as Synthesizing CDK app..., the CDK app's own stderr, and
--verbose output. A terminal shows both streams together, so the text you
see there is unchanged. To merge the streams in a script, use 2>&1.
Every command's stdout at a glance
| Command | When stdout carries only the document |
|---|---|
cdkd synth, cdkd list, cdkd state list, cdkd local invoke, cdkd local invoke-agentcore |
Always |
cdkd state resources, cdkd state show, cdkd state info, cdkd drift, cdkd diff, cdkd events |
Under --json only |
cdkd deploy, and the cdkd local servers (start-api, run-task, start-service, start-agentcore, start-alb, start-cloudfront, start-web-function, start-microvm) |
Never |
Without --json, the commands in the second row print a formatted view for a
person, and their progress lines stay on stdout with that view.
The commands in the third row use stdout for the progress display, the route table or container logs, so there is no document to capture.
Edge cases
cdkd diff --json. It keeps stdout to the document by lowering the log level to warnings, not by moving progress to stderr. Progress and--verboseoutput are not printed at all, and only warnings and errors reach stderr.cdkd state list --longand--tree. These print a formatted view, not a record per line. The view still goes to stdout, and cdkd's progress lines go to stderr as they do on the plain listing.CDKL_LOG_LEVELorCDKL_LOG_STREAMset on the twolocal invokecommands. The bundled cdk-local engine's lines, such asBuilding container image (platform=...), go to stderr through cdkd's logger. With either variable exported, the engine keeps its own logger and prints them on stdout, ahead of the response.- The container's own output. The Lambda runtime emulator's
START,ENDandREPORTlines and every handler log line go to stderr.
Related
cdkd synth: what the template on stdout looks likecdkd list: the listing formatscdkd diff --json: the documentcdkd diffkeeps stdout to- Exit codes: the other half of scripting cdkd
- CLI Reference: every command and the shared options