Getting this error with TF 0.7.3, didn't happen on 0.7.1 and doesn't happen with 0.7.2.
I ran terraform get after downloading the new binary and that resulted in this error, which happens now whenever I plan. Downloading and using the 0.7.2 binary seems to fix it.
Running with TF_LOG=1 doesn't offer much info since it fails quite early I guess. Our infrastructure is too big to try and post the configuration, but since nothing changed on our side between those version then I guess it might be regression that'll be easier to spot. Let me know if I can provide further information.
Hi @eyalzek
I am sorry you are getting an error here. We added this as a potential incompatibility in the CHANGELOG and it seems to have certainly caught you :(
Terraform now validates the uniqueness of variable and output names in your configurations.
In prior versions certain ways of duplicating variable names would work.
This is now a configuration error (and should've always been). If you get an error running
Terraform you may need to remove the duplicates. Done right, this should not affect the
behavior of Terraform.
Paul
You're entirely right, I had the variable key_name declared somewhere where it shouldn't have been declared. Thanks!
Glad you got this resolved @eyalzek
:)
I'd just like to ask a follow up question as I've not interacted with Terraform since v0.6.3.
With this change, if you have multiple files that use the same variable name, for example:
variable "env_name" {}
Are you now expected to define that as a unique variable for each file?
I've tried simply removing the duplicates and leaving 1 of each, but that throws errors saying variable names are missing.
Is there perhaps some more in-depth documentation I can read about this so I can resolve it myself.
Thanks!
@akramhussein +1
@akramhussein @clearly I've been struggling with this as well, and determined it was related to how my modules were set up. Turns out what I was missing is that the uniqueness constraint is within a given directory. In other words, a module maps to a directory, and you can only have one variable definition per module/directory. I had multiple .tf files per module/directory, each one defining its variables.
What I did to solve it is move any shared variables into a single common.tf file per module/directory. The disadvantage to this approach is your individual .tf files will no longer entirely self-document their variable options, so I went one step further and moved all variables definitions into each modules common.tf file.
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.
Most helpful comment
I'd just like to ask a follow up question as I've not interacted with Terraform since v0.6.3.
With this change, if you have multiple files that use the same variable name, for example:
variable "env_name" {}Are you now expected to define that as a unique variable for each file?
I've tried simply removing the duplicates and leaving 1 of each, but that throws errors saying variable names are missing.
Is there perhaps some more in-depth documentation I can read about this so I can resolve it myself.
Thanks!