-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
v0.21+: Pessimistic operator ~>
for Terraform version detection not working as expected
#2806
Comments
The terraform {
# results in 1.x pin
required_version = "~> 1.0"
} terraform {
# results in 1.0.x pin
required_version = "~> 1.0.0"
} But youre saying that this results terraform {
# results in 1.0.x pin instead of 1.x pin as mentioned by the tf docs
required_version = "~> 1.0"
} But if that isn't working as expected then perhaps try If that doesn't work, then perhaps it's an issue in the library we're using? If so, then the best way to raise the issue is in the librarary's issues page. Line 42 in 585ce1e
The original PR is #1776 from @fblgit (in case you know the answer here). |
Forgot to link the actual Terraform documentation about the pessimistic operator. In reality Atlantis is complying properly, version 1.0.11 is valid for a The issue is more related to the difference in behaviour between Terraform and Atlantis. When you do a
This is not ideal because you'd be saying that your Terraform code is compatible with Terraform v2, which is not an issue at the moment but could be if an eventual v2 release happens. |
From the link to the pessimistic operator you provided
So it sounds like an issue with our 3rd party library? We're using the latest oct 27 2022 release https://github.com/warrensbox/terraform-switcher/releases/tag/0.13.1300 |
Related issues
Seems like it was fixed in 0.13.1218 and we're using 0.13.1300 so perhaps there was a regression? Those issues are closed but it's worth reopening or commenting. @Roberdvs could you follow up with them? |
~>
for Terraform version detection not working as expected~>
for Terraform version detection not working as expected
~>
for Terraform version detection not working as expected~>
for Terraform version detection not working as expected
Community Note
Overview of the Issue
Atlantis 0.21 introduced a feature to autodetect the Terraform version based on version constraints since it previously only did when an exact version was specified.
Based on my experience, this isn't working as someone familiar with Terraform version constraints for providers and modules would expect.
When specifying
version ~> 1.0
for modules and providers, Terraform uses the latest minor version of the 1.x major. Meanwhile, when specifyingrequired_version ~> 1.0
for Terraform core versions, Atlantis is using the lowest version amongst the ones it has installed, i.e:1.0.11
.Furthermore, with this same version constraint in v0.20, Atlantis was using the default Terraform version (Terraform 1.3) so this might even be considered a regression when upgrading to 0.21. Now, even when specifying a default TF version in Atlantis server, it's still picking 1.0.11.
In summary, I would expect
required_version ~> 1.0
to pick the latest available minor version, either from the ones Atlantis has locally installed or by detecting the latest one available to download, which mirrors Terraform behaviour for modules and providers.Reproduction Steps
Create a project with the following Terraform version constraint:
Expected behaviour. Atlantis uses the latest minor version available at the time.
Actual behaviour. Atlantis is using version 1.0.11
As a workaround specifying
required_version ~> 1.3
makes Atlantis use Terraform 1.3.5.Logs
Environment details
Atlantis 0.21.0
ATLANTIS_DEFAULT_TF_VERSION : v1.3.5
Let me know if there's more information I can provide to help with troubleshooting and thank you very much for the effort put behind this project ❤️
The text was updated successfully, but these errors were encountered: