-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Variable should be type string, got number #7962
Comments
I'm facing this one too, it also happens when supplying the value as a cli parameter:
In my
Also tried without All the above variations give me the same error:
|
@denisbr Seeing the same thing when supplying var on the cli. I've tried nearly every combination imaginable and haven't discovered a temporary workaround. I've reverted back v.0.6.16. There must be a bug in whatever "magic" is performing the type validation. For my use case, I'm specifying the short version of a git sha as a terraform variable:
The result of this can contain all numbers, all letters, or a combination of letters and numbers (and also may start with either a letter or a number). Before updating to 0.7, I did not explicitly define the variable type and did not run into any issues. When a variable's type is explicitly defined, perhaps there should be an attempt to cast that variable to a string (numbers -> string of numbers) prior to validation? EDIT - Pull request 7977 is open for this. |
Hey folks - sorry for the trouble here! You can work around this by wrapping double quotes around the flag, but you have to make sure your shell passes them through to Terraform. So, to use @denisbr's example, this should work:
We'll be landing #7977 shortly and the fix will be out in v0.7.1 soon! |
@phinze Thanks for giving a workaround suggestion, I'll wait for the fix to land in 0.7.1 and stay on 0.6.x for a little longer. |
The same error happens with boolean vars too. The same workaround works.
|
Was this not supposed to be resolved in 0.7.1? as im still seeing it wen running the below code
|
@fluzz seeing the same thing on 0.7.1. No reference to this issue in the changelog. The workaround mentioned above won't solve my specific use-case (passing bash vars to TF vars). Ultimately I switched over to loading the variables from a file (which is dynamically generated from bash prior to terraform execution). |
Seeing the same thing on 0.7.2 as well. Can't seem to get the workaround to work on 0.7.2 either. |
@phinze Care to enlighten us on this issue? It's still keeping me from going to 0.7.x. |
I am seeing the same thing with 0.7.2 |
Seeing the same behavior in 0.7.3 |
@akoeb-zalando the workaround still works though:
|
Seeing this too in 0.7.2 and 0.7.3. @phinze workaround works well:
|
Seeing this on 0.7.3 as well |
Don't either @phinze or anyone at hashicorp care about this at all? Not a quick word on this? @mitchellh ? |
@denisbr We do! Because this bug has a workaround, we prioritize bugs that don't have workarounds first since they're obvious blockers. But this bug is tagged and we handle core bugs as quickly as possible. If you want to see it done quicker I encourage a pull request according to our contribution guide which is detailed. If that is followed (helpful checkboxes guide you the way) then we can merge very, very quickly. I promise we'll get to it. :) |
Just as a reminder to all, the recommended workaround doesn't help when you're passing through bash variables. For this use case, you'll need to create a variable file and load them that way. |
Ok, thanks. Just a very long thread without any word from hashicorp. I'm
|
New to terraform here. |
Also hitting this bug after upgrading to 0.7 but we're using |
I found a work around by using quotes when assigning the values in the var file. |
@baboune can you elaborate on your workaround? |
@dayer4b In my case, the trick was in the .tfvars file by adding " " around integer values. By treating everything as String, then the parser can convert it to number, and it works. Example:
Then in variable.tf: Finally in terraform.tfvars |
ahh, I see. thanks! |
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. |
In Terraform 0.7 I have observed an issue with handling numeric variables. To replicate this issue, you need to create two files,
main.tf
:And
terraform.tfvars.json
:Running
terraform apply
produces the following error:The text was updated successfully, but these errors were encountered: