Skip to content
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

Bug: Tfswitch not following documented precedence #491

Closed
prashantkalkar opened this issue Jul 17, 2024 · 2 comments · Fixed by #492
Closed

Bug: Tfswitch not following documented precedence #491

prashantkalkar opened this issue Jul 17, 2024 · 2 comments · Fixed by #492
Labels
bug Something isn't working documentation Add or improve documentation: README/CHANGELOG/comments on code

Comments

@prashantkalkar
Copy link

I am using the tfswitch for terraform module development. As part of the development, we set the required terraform version in the .tfswitchrc file.

The .tfswitchrc file is set as follows.

1.8.5

The terraform versions.tf file is configured as follows:

terraform {
  required_version = ">= 1.8.5"
  ...
  }
}

The intension behind this setup is that. The module can be used by any terraform code >= 1.8.5 but during the module development itself the TF version should be fixed at 1.8.5. Ensuring tf version at 1.8.5 during module development ensures that module does not include any newer TF features which will break older clients which are on 1.8.5.

This earlier used to work but recently during tfswitch its choosing latest TF version:

$ tfswitch
17:18:43.624 INFO Reading configuration from "<REDACTED>/.tfswitchrc"
17:18:43.631 INFO Reading version from Terraform module at "."
17:18:43.736 INFO Reading required version from constraint: ">= 1.8.5"
17:18:43.737 INFO Matched version: "1.9.2"
17:18:43.737 INFO Switched Terraform to version "1.9.2"

This breaks the precedent order documented at: https://tfswitch.warrensbox.com/usage/general/

Please let me know if this expected or a regression bug.

@yermulnik
Copy link
Collaborator

@prashantkalkar It looks like we've missed to adjust docu when we had made the change and the order of precedence left reversed in the docu (see this discussion for details on the order).

The resolution for your use case would be to switch from TOML config file to TF_VERSION env var to override required version explicitly and forcibly.

@yermulnik
Copy link
Collaborator

PR: #492

@yermulnik yermulnik added bug Something isn't working documentation Add or improve documentation: README/CHANGELOG/comments on code labels Jul 17, 2024
@yermulnik yermulnik linked a pull request Jul 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Add or improve documentation: README/CHANGELOG/comments on code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants