AWS CDK apps are effectively only a definition of your infrastructure using code. When CDK apps are executed, they produce (or “synthesize”, in CDK parlance) an AWS CloudFormation template for each stack defined in your application.
To synthesize a CDK app, use the
cdk synth command. Let’s check out the template synthesized from the sample app. Because our app includes two stacks we need to tell the
cdk synth command which stack we want to synthesize. You can get a list of available stacks:
The CDK CLI requires you to be in the same directory as your cdk.json file. If you have changed directories in your terminal, please navigate back now.
We can then synthesize one of the stacks:
This will output the following CloudFormation template.