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 synth generates only json files when used with -o

See original GitHub issue

We don’t have plans to output YAML to cdk.out

The cdk.out directory is a build artifact and generally intended to be read by machines and not by humans. As such we want to make sure it’s contents are deterministic and consistent and YAML is less stable then JSON (there are quirks related to yaml version, parsing, multi-line, etc).

Any yaml parser should be able to read json out of the box because YAML is designed as a superset of json (all json is valid yaml).

If you need to convert json to human readable yaml, there are many many tools you could use.

Original post

Describe the bug cdk synth ignores -j option when used with -o. It will always produce json files even if -j is false or not present. As a result, it is not possible to synthesize yaml files in a given directory.

To Reproduce cdk synth <stack> -o stacks cdk synth <stack> -j false -o stacks

Expected behavior There should be yaml files in the stacks dir.

Version:

  • OS MacOS
  • CDK Version 0.34.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:23
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

15reactions
evmincommented, Sep 4, 2020

YAML is much easier to read for the human eye. Could be useful to have an explicit YAML option for the situations when the app needs to be distributed as a template.

12reactions
robertdcommented, Jul 8, 2019

Honestly, current workflow is somewhat confusing (reference: https://github.com/awslabs/aws-cdk/pull/2636#issuecomment-496970443).

If I have a single stack and I run cdk synth I get YAML in the stdout. But if I have multiple stacks, then I get JSON in cdk.out. I agree with @markusl that It would be nice to have --all option and YAML option as well (more readable for humans imho). For example cdk deploy "*" uses wildcards, perhaps cdk synth should too.

Also, in our CI/CD pipeline we have cdk synth and cdk diff step that shows user CloudFormation template and proposed changes before moving forward (cdk deploy step is manual trigger in Gitlab CI/CD). Therefore it would be really nice if we can have YAML option back.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS CDK Toolkit (cdk command) - AWS Documentation
The cdk synth command simply prints the generated templates for one or more specified stacks. See cdk synth --help for all available options....
Read more >
How to get JSON Output from CDK Synth in AWS CDK
The cdk synth command outputs the CloudFormation equivalent of our CDK stack and stores the template as json in the cdk.out directory.
Read more >
AWS CDK synth and different cdk.json files - Stack Overflow
When, I run a synth or deploy, can I specify a specific json file instead of the default cdk.json one? I know you...
Read more >
cdk synth | AWS CDK Workshop
AWS CDK apps are effectively only a definition of your infrastructure using code. When CDK apps are executed, they produce (or “synthesize”, ...
Read more >
AWS CDK Pipelines: Real-World Tips and Tricks (Part 2)
In each CDK Pipelines application, create a configuration.py file that contains those classes: Snippet of application specific config classes. You can now use...
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