atlantis icon indicating copy to clipboard operation
atlantis copied to clipboard

Atlantis can't detect Terraform version if constraint is not exact

Open m-ronchi opened this issue 2 years ago • 4 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

my terraform projects declare required version as

terraform {
  required_version = "~> 1.1.0"
}

when I upgraded atlantis to 0.19.4, all plans started failing with

│ Error: Unsupported Terraform Core version
│ 
│   on main.tf line 5, in terraform:
│    5:   required_version = "~> 1.1.0"
│ 
│ This configuration does not support Terraform version 1.2.0. To proceed,
│ either choose another supported Terraform version or update this version
│ constraint. Version constraints are normally set for good reason, so
│ updating the constraint may lead to other errors or unexpected behavior.

atlantis should detect the terraform version to use even if is not exact, and use a compatible version for plans & applies

m-ronchi avatar Jun 09 '22 10:06 m-ronchi

@m-ronchi , I found a workaround. I specified --default-tf-version=v1.2.2 in the server and we're now planning again. I suspect there may be situations where that doesn't work (someone has specified a not greater than using an inexact version), but I wanted to mention this workaround in case it helps us understand the root cause.

MarkIannucci avatar Jun 10 '22 13:06 MarkIannucci

@m-ronchi , I found a workaround. I specified --default-tf-version=v1.2.2 in the server and we're now planning again. I suspect there may be situations where that doesn't work (someone has specified a not greater than using an inexact version), but I wanted to mention this workaround in case it helps us understand the root cause.

Another workaround could also be to specify the version on the repository config atlantis.yaml, from: runatlantis.io/docs/repo-level-atlantis-yaml.html:

version: 3
projects:
- dir: project1
  terraform_version: 1.1.0

daconstenla avatar Jun 16 '22 17:06 daconstenla

This is not a bug and in fact is documented:

Alternatively, one can use the terraform configuration block's required_version key to specify an exact version

Could be a feature request though.

kpocius avatar Jun 17 '22 08:06 kpocius

Could be a feature request though.

this. there is no template for feature requests though.

m-ronchi avatar Jun 17 '22 08:06 m-ronchi

should be changed to feature?

jamengual avatar Aug 26 '22 04:08 jamengual