-
Notifications
You must be signed in to change notification settings - Fork 450
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
getNumberAttribute() returns number instead of reference #679
Comments
|
I can confirm this is also happening in 0.2.2, |
Hey @STollenaar |
@ansgarm not really, I unfortunately need a number as the output, but whenever you try to cast it to a number it will just go to that negative float. |
Ah, I see. How did you try to cast it? In TS/JS or with the tonumber Terraform function? I suspect using the latter could work, but I haven't tried. |
I tried it with the TS/JS casting. Wasn't sure how to use the Terraform function for this, which in theory could work if we get that reference from the getStringAttribute |
@STollenaar what are you trying to do with the number? Assign to a different property of type number? Assign to a string property? Do operations based on the number value? |
@jsteinich somehow I missed the notification of your comment. But I was passing it to another Data resource which is doing some operations on it (Basically convert to GiB) and I was doing some direct operations on it (Just calling Math.min). |
The actual value from a data source isn't available during synth. If the values are know at synth time, then using them directly is your best bet; otherwise, need to use Terraform functions via escape hatches. |
I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Community Note
cdktf & Language Versions
0.3.0
Affected Resource(s)
import { DatabaseCluster } from "./.gen/providers/digitalocean";
(generated from
"digitalocean/digitalocean@~> 2.8.0"
)Debug Output
Expected Behavior
db.port
should synthesize to Terraform reference instead of number:This workaround can achieve the above:
Actual Behavior
synthesizes to
Steps to Reproduce
The above code originates from my CDK Day talk example.
Important Factoids
References
The text was updated successfully, but these errors were encountered: