Open mattnworb opened 5 years ago
Hi @mattnworb ! Thanks for opening this issue, and sorry for the confusing behavior.
I re-titled the issue to focus on the output. We aren't going to make many more changes to the behavior of terraform 0.12upgrade
, but we can and should print a more informative error message in this particular instance - similarly, in cases where a root module and child module both have a required_version
- to let the user know where the version is set.
@teamterraform thanks, that sounds like it would be very helpful 👍
If you run
terraform 0.12upgrade
to upgrade a module or a repo to the 0.12 syntax, any existingterraform.required_version
attributes are not changed - but0.12upgrade
will add a newversions.tf
file to the directory with:After successfully executing
terraform 0.12upgrade
, a subsequentterraform init
will fail withIt took me a while to figure out that this was caused by a
terraform
block inmain.tf
which was also setting the required_version like below.I think ideally
terraform 0.12upgrade
would remove any now-out-of-daterequired_version
blocks when it mutates the files, and/or the error message about "does not support Terraform version x.y.z" could point to exactly which line in which .tf file was used as therequired_version
source of truth, to aid in finding the problem.Terraform Version
Terraform Configuration Files
in main.tf, before running
terraform 0.12upgrade
:after running
terraform 0.12upgrade
, the main.tf above is unchanged, but versions.tf is added with:Debug Output
https://gist.github.com/mattnworb/327d9388a4ab687e72f55f959e121e07
note that the trace output does not indicate which line/file any discovered instances of
recognized_version
are used fromSteps to Reproduce
terraform.required_version
set to"~> 0.11.13"
or something similar in a file not namedversions.tf
.terraform 0.12upgrade
terraform init
, observe the error output that the version is not supported.