How to get JSON Output from CDK Synth in AWS CDK


Borislav Hadzhiev

Sat Apr 17 20211 min read

In order to get JSON output from the `cdk synth` command we have to use the `--json` flag

Getting JSON Output from CDK Synth #

The cdk synth command outputs the CloudFormation equivalent of our CDK stack and stores the template as json in the cdk.out directory.

However, the command's output to the terminal is in yaml format.

In order to output JSON from the cdk synth command we have to add the --json flag.

npx cdk synth --json

Issuing the command on a CDK stack, that consists of a single S3 bucket shows the following output:

cdk synth json output

Further Reading #

Join my newsletter

I'll send you 1 email a week with links to all of the articles I've written that week

Buy Me A Coffee