cdk synth generates only json files when used with -o
See original GitHub issueWe 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:
- Created 4 years ago
- Reactions:23
- Comments:16 (9 by maintainers)
Top GitHub Comments
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.
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 incdk.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 examplecdk deploy "*"
uses wildcards, perhapscdk synth
should too.Also, in our CI/CD pipeline we have
cdk synth
andcdk 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.