How to get JSON Output from CDK Synth in AWS CDK


Borislav Hadzhiev

Thu Apr 14 20221 min read

Updated - Thu Apr 14 2022

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 aws-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 #

Use the search field on my Home Page to filter through my more than 1,000 articles.