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

Issue importing with CfnInclude when template do not have quotes #13709

Closed
vincent851 opened this issue Mar 20, 2021 · 5 comments · Fixed by #13745
Closed

Issue importing with CfnInclude when template do not have quotes #13709

vincent851 opened this issue Mar 20, 2021 · 5 comments · Fixed by #13745
Assignees
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@vincent851
Copy link

vincent851 commented Mar 20, 2021

I encounter this issue when trying to import CloudFormation YAML Template to create IAM role.

The template have the following header:
AWSTemplateFormatVersion: 2010-09-09
and also version with date
Version: 2012-10-17.

The error I encounter is when trying to deploy the template to the AWS via CDK.
The build is fine but when deploying I encounter the following error:
failed: Error [ValidationError]: Template format error: unsupported value for AWSTemplateFormatVersion.

I noticed that the same template can be deploy via AWS CLI and validated without issue using:
aws cloudformation create-stack --stack-name
and
aws cloudformation validate-template --template-body

I think this is a bug because AWS CLI have no issue with this why would deploying via CDK raises error.

Reproduction Steps

Deploying via CDK with any template with the above header would work that do not have quotes around the date.

What did you expect to happen?

it would throw an error
failed: Error [ValidationError]: Template format error: unsupported value for AWSTemplateFormatVersion.

What actually happened?

failed: Error [ValidationError]: Template format error: unsupported value for AWSTemplateFormatVersion.

Environment

  • CDK CLI Version :1.81.0
  • Framework Version:
  • Node.js Version:
  • OS : MacOS
  • Language (Version): Typescript

Other


This is 🐛 Bug Report

@vincent851 vincent851 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 20, 2021
@skinny85 skinny85 self-assigned this Mar 22, 2021
@skinny85
Copy link
Contributor

Hi @vincent851 ,

Thanks for opening the issue. Can you please attach the template that is causing this error?

Thanks,
Adam

@skinny85 skinny85 added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Mar 22, 2021
@vincent851
Copy link
Author

vincent851 commented Mar 22, 2021

AWSTemplateFormatVersion: 2010-09-09
Resources: 
  RootRole: 
    Type: "AWS::IAM::Role"
    Properties: 
      AssumeRolePolicyDocument: 
        Version: 2012-10-17
        Statement: 
          - 
            Effect: "Allow"
            Principal: 
              Service: 
                - "ec2.amazonaws.com"
            Action: 
              - "sts:AssumeRole"
      Path: "/"
  RolePolicies: 
    Type: "AWS::IAM::Policy"
    Properties: 
      PolicyName: "root"
      PolicyDocument: 
        Version: 2012-10-17
        Statement: 
          - Effect: "Allow"
            Action: "*"
            Resource: "*"
      Roles: 
        - Ref: "RootRole"
  RootInstanceProfile: 
    Type: "AWS::IAM::InstanceProfile"
    Properties: 
      Path: "/"
      Roles: 
        - Ref: "RootRole"

@vincent851
Copy link
Author

I am editing the above to remove the quotes to match the issue I have. the above will still work with AWS CLI but will not work when deploying via CDK. the CDK Will built but deployment will fail

@skinny85
Copy link
Contributor

Thanks for the template @vincent851 . I can confirm I'm able to reproduce the problem. I have a guess what happens (the YAML library interprets 2010-09-09 as a Date instead of a String). I'm working on a fix.

skinny85 added a commit to skinny85/aws-cdk that referenced this issue Mar 22, 2021
Currently, we are using the `yaml-1.1` schema when de-serializing YAML documents,
Unfortunately, this has the side effect of treating unquoted parts of the template like '2010-09-09'
as Date objects, instead of just simple strings.
This has been noted by a customer using the cloudformation-include module,
but I assume a very similar problem exists for other places we parse YAML,
like cloudformation-diff.

Switch to the `core` schema from `yaml-1.1`,
where those are treated as strings, instead of dates.

Fixes aws#13709
@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Mar 23, 2021
skinny85 added a commit to skinny85/aws-cdk that referenced this issue Mar 26, 2021
Currently, we are using the `yaml-1.1` schema when de-serializing YAML documents,
Unfortunately, this has the side effect of treating unquoted parts of the template like '2010-09-09'
as Date objects, instead of just simple strings.
This has been noted by a customer using the cloudformation-include module,
but I assume a very similar problem exists for other places we parse YAML,
like cloudformation-diff.

Switch to the `core` schema from `yaml-1.1`,
where those are treated as strings, instead of dates.

Fixes aws#13709
@mergify mergify bot closed this as completed in #13745 Mar 30, 2021
mergify bot pushed a commit that referenced this issue Mar 30, 2021
Currently, we are using the `yaml-1.1` schema when de-serializing YAML documents,
Unfortunately, this has the side effect of treating unquoted parts of the template like '2010-09-09'
as Date objects, instead of just simple strings.
This has been noted by a customer using the cloudformation-include module,
but I assume a very similar problem exists for other places we parse YAML,
like cloudformation-diff.

Switch to the `core` schema from `yaml-1.1`,
where those are treated as strings, instead of dates.

Fixes #13709

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Mar 31, 2021
Currently, we are using the `yaml-1.1` schema when de-serializing YAML documents,
Unfortunately, this has the side effect of treating unquoted parts of the template like '2010-09-09'
as Date objects, instead of just simple strings.
This has been noted by a customer using the cloudformation-include module,
but I assume a very similar problem exists for other places we parse YAML,
like cloudformation-diff.

Switch to the `core` schema from `yaml-1.1`,
where those are treated as strings, instead of dates.

Fixes aws#13709

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Aug 26, 2021
Currently, we are using the `yaml-1.1` schema when de-serializing YAML documents,
Unfortunately, this has the side effect of treating unquoted parts of the template like '2010-09-09'
as Date objects, instead of just simple strings.
This has been noted by a customer using the cloudformation-include module,
but I assume a very similar problem exists for other places we parse YAML,
like cloudformation-diff.

Switch to the `core` schema from `yaml-1.1`,
where those are treated as strings, instead of dates.

Fixes aws#13709

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants