question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cdk synthesize clarification

See original GitHub issue

❓ General Issue

The Question

According to the documentation the cdk synthesize command synthesizes and prints the CloudFormation template for the given stack. But in reality it prints the template of the given stack and outputs every stack’s template to cdk.out. I don’t know if this is a bug or the intended behavior. In the latter case why was it implemented this way? Why does it print to the console and output to the directory at the same time?

Environment

  • CDK CLI Version: 1.39.0 (build 5d727c1)
  • Module Version:
  • OS: Windows 10
  • Language: CLI

Other information

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
shivlakscommented, May 22, 2020

@suhaig thanks for letting us know about that. it seems like the documentation needs a bit of a refresh. copy @Jerry-AWS

cdk synth prints out the given stack. If you have multiple stacks, you should see a message that indicates the stacks that were synthsized.

const app = new cdk.App();
new ExampleStack(app, 'ExampleStack');
new ExampleStack(app, 'MyOtherExamplestack');

cdk synth would render to

Successfully synthesized to some/path/cdk.out
Supply a stack id (ExampleStack, MyOtherExamplestack) to display its template.

The printed output is intended to be human readable (which is why we render it in YAML). The cdk.out folder is the default directory in which the synthesized cloud assembly is stored. It’s used during deploy and stores the templates in JSON. We do not expect users to interact directly with the cloud assembly. Learn more about the cloud assembly schema here

@strottos you do not need to run synth ahead of a deploy, the CDK will handle that for you. If a cloud assembly directory does not exist (i.e. cdk.out), it will create one, synthesize the cloud assembly, and then deploy from that assembly.

0reactions
SomayaBcommented, Jun 22, 2020

Closing this issue since it seems to have been resolved by #8264. Feel free to reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS CDK Toolkit (cdk command) - AWS Documentation
All CDK Toolkit commands start with cdk , which is followed by a subcommand ( list , synthesize , deploy , etc.). Some...
Read more >
With CDK, how do I synthesize stack via sdk OR how do I get ...
A stack can be accessed as a string from CDK as follows: app.synth().getStack(STACK_NAME).template (Python).
Read more >
AWS CDK Pipelines: Real-World Tips and Tricks (Part 2)
Snippet of how to create a personal stage separate from the CDK pipeline. Build the CDK app and synthesise the CloudFormation templates locally...
Read more >
Glossary of CDK application - Part 2
synth(): Synthesize this stage into a cloud assembly. ⁠Once an assembly has been synthesized, it cannot be modified. Subsequent calls will ...
Read more >
How to become an infrastructure-as-code ninja, using AWS CDK
Our goalsFirst, let us clarify what we want to accomplish here:An EC2 ... state * `cdk synth` emits the synthesized CloudFormation template ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found