Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function dump_yaml sometimes converted string values to number values, causing invalid CFN templates #1

Closed
canhnt opened this issue May 27, 2019 · 1 comment

Comments

@canhnt
Copy link

canhnt commented May 27, 2019

Description

When parsing YAML files containing string scalar longer than 8 chars and start with 0, the function 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.

Use-case '012345678'

Reproduction script:

import cfn_tools
content = "Parameters:\n  MyAccountId:\n    Type: String\n    Default: '012345678'"
body = cfn_tools.load_yaml(content)
template_body = cfn_tools.dump_yaml(body)
print template_body

Expected output:

Parameters:
  MyAccountId:
    Type: String
    Default: '012345678'

Actual output:

Parameters:
  MyAccountId:
    Type: String
    Default: 012345678

Use-case '01234567'

import cfn_tools
content = "Parameters:\n  MyAccountId:\n    Type: String\n    Default: '01234567'"
body = cfn_tools.load_yaml(content)
template_body = cfn_tools.dump_yaml(body)
print template_body

Output:

Parameters:
  MyAccountId:
    Type: String
    Default: '01234567'
@canhnt
Copy link
Author

canhnt commented May 28, 2019

Close the issue because the bug is for https://github.com/awslabs/aws-cfn-template-flip

@canhnt canhnt closed this as completed May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant