Closed canhnt closed 5 years ago
Workaround solution:
import cfn_tools
import cfn_flip
content = "Parameters:\n MyAccountId:\n Type: String\n Default: '012345678'"
body = cfn_tools.load_yaml(content)
template_body_json = cfn_tools.dump_json(body)
template_body_yaml = cfn_flip.to_yaml(template_body_json)
print template_body_yaml
Output
Parameters:
MyAccountId:
Type: String
Default: '012345678'
This is related with the pyYaml and this: https://github.com/yaml/pyyaml/issues/98
But I will work in a workaround to deal with AWS AccountId in the conversion. :-)
The PR: https://github.com/awslabs/aws-cfn-template-flip/pull/79 should fix the issue.
Thank you for your fix. I think it would be nice when PR is merged to master, we can close the issue. Otherwise the bug is still valid in the the latest branch (master).
Sure, I've closed too early :-)
Fixed in #79 :)
Thanks. It'll be released in the next tag, i.e. after v1.2.0
Yes. After the next PR is merged, I'll be releasing as v1.2.1. Hopefully today.
Description
When parsing YAML files containing string scalar longer than 8 chars and start with 0, the function
cfn_tools.dump_yaml
strips single (and double) quotes, which converts string scalar to number scalar. When CFN templates refers these string values in Ref or Sub functions, it causes template error.Package version: 1.2.0
Test-cases
1. Test case '012345678'
Expected output:
Actual output:
2. Test-case
'01234567'
Output: