cdk synth Command Reference
Synthesize a CDK app into CloudFormation templates.
cdk synth evaluates your CDK app and emits the CloudFormation templates and the cloud assembly. It is the validation and artifact step you run before deploy.
What it does
cdk synth produces the CloudFormation templates and cloud assembly (cdk.out) for your stacks without deploying. It is the fastest way to validate that an app compiles and to capture a deployable artifact for review.
Common flags and usage
- STACK_NAME: synthesize a single stack
- --all: synthesize every stack
- --output DIR: write the cloud assembly to a directory (default cdk.out)
- --context KEY=VALUE: pass synthesis context
- --quiet: suppress template output to stdout
Example
- name: CDK Synth
run: npx cdk synth --all --output cdk.out
- name: Upload cloud assembly
uses: actions/upload-artifact@v4
with:
name: cdk-out
path: cdk.out/In CI
Run synth on pull requests as a fast compile-and-validate check that needs no AWS credentials. Persist cdk.out as an artifact so a later deploy job applies the exact assembly that was reviewed, rather than re-synthesizing from a possibly different commit.
Key takeaways
- synth emits CloudFormation templates and the cloud assembly without deploying.
- It needs no AWS credentials, so it is an ideal PR validation step.
- Persist cdk.out as an artifact so deploy applies the reviewed assembly.