Since I've seen Hashicorp Terraform, I have been wondering why the "plan" it can export has binary format.

Now in the AWS world you have got a declarative configuration language called CloudFormation which can be abstracted from using AWS CDK (Cloud Development Kit) in a common programming language of your choice.

Therefore my question: imagine somebody familiar with CloudFormation would like to see what CDK code will do. Is there a way to export a CloudFormation file using CDK?

  • So from your experience there's no way to export CF file from terraform code?
    – koalaok
    Apr 9, 2022 at 10:03

2 Answers 2


Yes: in the hello world CDK example, they call it "synthesizing":

cdk synth

^^ produces CloudFormation file.

  • The only problem is that sometimes synth requires online access (if your lambda is in VPC). Dec 11, 2023 at 13:52

As Tamara had already mentioned, CDK already produces this for you during synthesis. To clarify this further, if you look in the cdk.out directory, you'll find a xxxxx.template.json file for every stack.

This is your synthesized template that CDK passes onto Cloudformation.

Additionally, you may also benefit from taking a look at cdk diff.

The cdk diff command compares the current version of a stack defined in your app with the already-deployed version, or with a saved AWS CloudFormation template, and displays a list of changes.

Let me know if you have any further questions!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.