-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Units of measure in numbers don't work as documented. #3287
Comments
If you guys can give me some pointers where to look, I can give a shot at trying to tackle this. |
https://terraform.io/docs/providers/aws/r/ebs_volume.html - "size - (Optional) The size of the drive in GB." |
I know. This was just a random example of a "valid" configuration file. The bug is not with the amazon provider, but with the fact that the documentation says units of measure are supported in number literals while they aren't What I'm trying to say is that the documenation states that in the syntax of configuration files (agnostic of provisioner or provider) integers are defined according to the following EBNF grammar:
which means the following
But instead we get
So the current implementation seems to be
Which is clearly a mismatch between documentation and implementation. So we have two ways to fix this. Update the documentation that units of measure aren't supported. Or add the feature to the configuration file parser. |
Per discussion on IRC, I modified your original example, so it's more obvious that this problem is provider/resource unrelated, yet still valid. |
We also discussed on IRC, that it would be useful to have a way to convert bytes to other units, so that one variable can be used for multiple resources, each expecting different units. variable "size" {
default = "1TB"
}
resource "aws_ebs_volume" "example" {
size = "${in_gb(var.size)}"
} https://botbot.me/freenode/terraform-tool/2015-09-21/?msg=50178901&page=1
|
I just came up against this when trying to create an elasticsearch domain on AWS and setting the
It would be great if "10Gb" expanded to the proper integer for the AWS API call |
With Terraform 0.6.12 I get no syntax error, but it looks like the suffixes do not have anny effect variable "size" {
default = 10kb
}
output "size_in_bytes" {
value = "${var.size}"
} Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
size_in_bytes = 10 |
+1 |
@dmacvicar Verified that that will give a syntax error now. So this is a huge misdocumentation. We had this feature as part of Terraform 0.1 and 0.2 but it has probably been broken since then since when we switched to HCL as the format, this didn't come along with it. We've chatted about it and decided to not support this feature (which has never really worked in any meaningful moment of history). Closing this and will update docs. Sorry! |
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 have 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. |
Version of terraform: v0.6.3
The documentation says that numbers should support units of measure. Meaning
1gb
should be a valid number. Except currently that doesn't seem to parse.Say we have:
it should work but instead we get:
I also tried
default = "10gb"
(enclosed in double quotes) but then we get:i.e. the size is parsed as string.
The text was updated successfully, but these errors were encountered: