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

tonumber() does not support 0x prefixed hexadecimal strings #22584

Closed
joe-bowman opened this issue Aug 24, 2019 · 1 comment · Fixed by #22747
Closed

tonumber() does not support 0x prefixed hexadecimal strings #22584

joe-bowman opened this issue Aug 24, 2019 · 1 comment · Fixed by #22747

Comments

@joe-bowman
Copy link

joe-bowman commented Aug 24, 2019

Terraform Version

0.12.7

Terraform Configuration Files

variable "v1" {
    default = "0x99"
}
output "input-v1" {
    value = tonumber(var.v1)
}

Expected Behavior

Hex string is parsed, and converted to a number (decimal 153).

Actual Behavior

Error: Invalid function argument

  on main.tf line 5, in output "input-v1":
   5:     value = tonumber(var.v1)
    |----------------
    | var.v1 is "0x99"

Invalid value for "v" parameter: cannot convert "0x99" to number; given string
must be a decimal representation of a number.

Additional Context

The above example is a reduced case. In the real life use case, the hex string is generated from the substring of a hash to deterministically determine AZ placement without placement changing if other nodes are torn down (i.e. can't use index.count) - so this must be represented as a string and converted to a number for lookup in a list. Worked under 0.11 and previous, so considered a bug in 0.12.

@ghost
Copy link

ghost commented Oct 18, 2019

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.

@ghost ghost locked and limited conversation to collaborators Oct 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants