Number attributes not synthed as references
See original GitHub issueCommunity Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave “+1” or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
cdktf & Language Versions
com.hashicorp:cdktf:0.9.0 “aws@~> 3.0” OpenJDK Runtime Environment (build 1.8.0_312-b10)
Affected Resource(s)
https://www.terraform.io/docs/providers/aws/r/memorydb_cluster https://www.terraform.io/docs/providers/aws/r/db_instance
Debug Output
Expected Behavior
db.port
should synthesize to Terraform reference instead of number:
"value": "${aws_memorydb_cluster.cluster_9AC9C0F1.cluster_endpoint.0.port}"
This workaround can achieve the above:
db.getStringAttribute("port")
Actual Behavior
db.port
synthesizes to:
"value": "-8.109562212591454E298"
Steps to Reproduce
I assume this happens for any provider when trying to synth number types.
Important Factoids
This seems to be a regression as I found #679 that was supposedly fixed in 0.6.0.
References
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Attributes and Aliasing - Datadog Docs
This provides guidance towards the naming convention, and discourages users from building assets (such as saved views or dashboards) based on non-standard ...
Read more >Binary Attribute - an overview | ScienceDirect Topics
The total number of attributes is p, where p = q + r + s + t. Table 2.3. ... For asymmetric binary...
Read more >Fine-Grained Attribute Analysis for Person Re-Identification
To our best knowledge, we are among the first attempts to explicitly dissect person re-ID from the aspect of attribute on synthetic dataset....
Read more >XML Information Set (Second Edition) - W3C
This list contains element, processing instruction, unexpanded entity reference, character, and comment information items, one for each element, ...
Read more >Chapter 4. The class File Format - Oracle Help Center
The value of the attributes_count item gives the number of attributes (§4.7) in the attributes ... A reference to this is not passed...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey folks, sorry for taking so long, but I have found the problem.
During synth your program transforms the number to a sting with Gson. After that CDKTF runs through all the numbers it knows of and translates them to terraform expressions if applicable. But your number is not a number anymore, it’s a string now so we dont catch it. To solve this issue right now you can use
Fn.jsonencode(testingResource)
and it works.The bigger question here is, can we make your current example work. I think we possibly can try to find things that look like numbers in all strings and see if they are known to us. For that we would need to check if a tokenized number can collide with another tokenized number if serialized to string. If we are sure this can not happen we can then search through every string for something that looks like a serialized number and replace this with the TF expression needed. The serialization format could vary between languages though, JS uses
e+
instead ofE
like Java for example. It could also be a custom serialization engine being used. So I guess it’s hard to get right all the time, but getting it right most of the time and never getting it wrong would be sufficient I thinkHello. I have created this repo to show the error happening. Hope that makes things more clear.
All you have to do is clone, then run the test class. It should print the synthesized string with the error. As you said, this really looks like a rounding error when the serialisation of the java class into json happens.