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

[cloudformation_include] Error while parsing json Cloudformation #11300

Closed
rrezino opened this issue Nov 5, 2020 · 5 comments · Fixed by #11323
Closed

[cloudformation_include] Error while parsing json Cloudformation #11300

rrezino opened this issue Nov 5, 2020 · 5 comments · Fixed by #11323
Assignees
Labels
@aws-cdk/cloudformation-include Issues related to the "CFN include v.20" package bug This issue is a bug. effort/small Small work item – less than a day of effort in-progress This issue is being actively worked on. p1

Comments

@rrezino
Copy link

rrezino commented Nov 5, 2020

I'm trying to follow the instructions here on how to create CDK code from existing Stacks. With the example case, it works fine, but when I try one real stack it fails. Probably a situation not covered on Json, but, I don't know what part is failing.

Reproduction Steps

  1. Follow the steps on : https://aws.amazon.com/blogs/developer/migrating-cloudformation-templates-to-the-aws-cloud-development-kit/
  2. Try to run the cdk diff with the following CF json file: https://textbin.net/J38M7i2FZ5

What did you expect to happen?

Get the CDK version of an existing Stack.

What actually happened?

jsii.errors.JSIIError: Expected 'true' or 'false' for boolean value, got: '${Token[TOKEN.151]}'
Subprocess exited with error 1

Environment

  • **CLI Version :1.71.0
  • **Framework Version:1.71.0
  • **Node.js Version:v14.13.0
  • **OS :macOS Catalina 10.15.7
  • **Language (Version):TypeScript

This is 🐛 Bug Report

@rrezino rrezino added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 5, 2020
@skinny85 skinny85 self-assigned this Nov 5, 2020
@skinny85
Copy link
Contributor

skinny85 commented Nov 5, 2020

Thanks for opening the issue @rrezino . Confirming I was able to reproduce it. Working on a fix.

@skinny85 skinny85 added @aws-cdk/cloudformation-include Issues related to the "CFN include v.20" package effort/small Small work item – less than a day of effort in-progress This issue is being actively worked on. p1 and removed needs-triage This issue or PR still needs to be triaged. labels Nov 5, 2020
@skinny85
Copy link
Contributor

skinny85 commented Nov 5, 2020

While I work on releasing a fix, you can actually unblock yourself with a small trick.

The problem is the "MultiAZ" property of the "DBInstance" resource. If you just edit the template to wrap it in a double Fn::Not:

{
  "Resources": {
    "DBInstance": {
       "Properties": {
         "MultiAZ": {
           "Fn::Not": [
             {
               "Fn::Not": [
                 {
                   "Fn::FindInMap": [
                     "Environment",
                     { "Ref": "Environment" },
                     "MultiAZ"
                   ]
                 }
               ]
             }
           ]
         },
         // ...

It doesn't change the meaning of the template, but allows it to be correctly included.

skinny85 added a commit to skinny85/aws-cdk that referenced this issue Nov 5, 2020
Including a template that was using an Fn::FindInMap expression for a boolean-typed property
would fail with an error similar to: "Expected 'true' or 'false' for boolean value, got: '${Token[TOKEN.151]}'".
The reason is that our Fn.findInMap() function in core incorrectly assumes Fn::FindInMap
can only return string values.
Change CfnParser to use a new, module-private function Fn._findInMap() that returns an IResolvable.

Fixes aws#11300
@mergify mergify bot closed this as completed in #11323 Nov 6, 2020
mergify bot pushed a commit that referenced this issue Nov 6, 2020
…#11323)

Including a template that was using an `Fn::FindInMap` expression for a boolean-typed property
would fail with an error similar to: `Expected 'true' or 'false' for boolean value, got: '${Token[TOKEN.151]}'`.
The reason is that our `Fn.findInMap()` function in `core` incorrectly assumes `Fn::FindInMap`
can only return string values.
Change `CfnParser` to use a new, module-private function `Fn._findInMap()` that returns an `IResolvable`.

Fixes #11300

----

*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

github-actions bot commented Nov 6, 2020

⚠️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.

@rrezino
Copy link
Author

rrezino commented Nov 9, 2020

Thanks Adam!

@skinny85
Copy link
Contributor

skinny85 commented Nov 9, 2020

No problem, thanks for reporting the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/cloudformation-include Issues related to the "CFN include v.20" package bug This issue is a bug. effort/small Small work item – less than a day of effort in-progress This issue is being actively worked on. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants