awslabs / aws-cfn-template-flip

Tool for converting AWS CloudFormation templates between JSON and YAML formats.
Apache License 2.0
994 stars 142 forks source link

Python package: ability for to_yaml() to receive input YAML data when performing cleanup of the YAML input #83

Closed mrinaudo-aws closed 4 years ago

mrinaudo-aws commented 5 years ago

As per the usage guide, the command line tool can be used to perform opinionated cleanup operations with the -c (or --clean) option. The -n (or --no-flip) option can be used to perform operations whilst keeping the same input data format. With the command line tool, I can then perform cleanup operations without switching input format, for example: cfn-flip -n -c my-test.json my-test1.json or cfn-flip -n -c my-test.yaml my-test1.yaml.

With the Python package instead, it does not seem to be possible to perform a cleanup if input data is YAML and to_yaml() is used; JSON input with to_json() seems to be working as expected. Assuming my_json_input_data is a CloudFormation template content in JSON format, to_json(my_json_input_data, clean_up=True) for example returns a JSON output processed with the cleanup logic. Assuming my_yaml_input_data is a CloudFormation template content in YAML format instead, to_yaml(my_yaml_input_data, clean_up=True) for example results in a json.decoder.JSONDecodeError.

Can you explore, if feasible, the possibility of having to_yaml() take YAML data as input?

Thank you for your time!

stilvoid commented 4 years ago

Fixed in d326d5eab64013f45d9ac53abf6937fb9c0d2f72

I'll be pushing a new version to pypi today :)