Currently, it appears that the code in project_command_builder.go only accepts terraform.required_version specifications that exactly specify a single version, rather than a range or other version constraint. Seems odd to have this limited behavior, as atlantis is built to support a wide range of terraform versions. It seems that the version constraints should be interpreted and the latest matching terraform version selected.
Also, the silent failure of the current approach is misleading.
Is there a reason why this was not implemented? Looking at the code, it seems reasonably straightforward to do so. Just need to get the list of all available terraform versions, which can be pulled from https://api.github.com/repos/hashicorp/terraform/tags
Or, slightly more hackily, could parse the HTML returned from ${TFDownloadURL}/terraform to get all the version numbers. But, that presumes that whatever URL is configured works similar to https://releases.hashicorp.com/terraform and provides a link tree.
I think this was likely not implemented because it makes the behaviour non-deterministic or because it was too difficult. I didn't implement it though so I can't say for sure :)
@llamahunter so you would want atlantis to download all terraform versions that match your non-exact constraint? It can't use that info to set a default version to use, though.
I would want it to download the _most recently available_ version that matches the version constraint.
Per the semver spec (which Terraform follows), the version with the greatest precedence shall be selected.
If a user wants to use a specific version of Terraform they can indicate that by using a = constraint.
The Terraform documentation specifically covers the Version Constraint Syntax and Version Constraint Behavior
~Any update on this request? It seems odd that this is considered a feature as opposed to a bug since it is ignoring the version constraint syntax that is supported by terraform. We have had to modify our version constraint from what we do with local development work to fit the needs of atlantis (to be explicit in version number).~
~Happy to help contribute as well if this is agreed to be something that can be supported! Seems like a number of members are facing similar issues.~
Ah my mistake, looks like this PR is in review but just taking some time to get out the door. I just need to be patient 馃槃
@jlestrada Feel free to give the PR a review if you have the cycles. I'm sure that would help it land more quickly
Will #1266 also read from .terraform-version?
@mcaulifn It uses the Terraform code to do the ingest and interpretation of versions, so the behaviour will be identical to that of Terraform
Most helpful comment
I would want it to download the _most recently available_ version that matches the version constraint.