warrensbox/terraform-switcher

Using versions.tf instead version.tf

Closed this issue · 2 comments

Hello,

Based on already solved issue (#69) I see, that this project support "version.tf" file.

However, this approach has limitations and can cause compatibility issues, as this file not contain only terraform version and as for me it's more reliable to call it "versions.tf", as I (and I hope others), have these filenames in projects: "subnets.tf", "instances.tf", etc.

For now, I use ENV variable to re-define one of the parameter to get tfswitch work.
Unfortunately, I didn't find any mention of "version.tf" in Go code to create PR for it.
Can you please help me with this issue?
Thank you in advance.

Hey @g3rhard
tfswitch uses github.com/hashicorp/terraform-config-inspect/tfconfig (https://github.com/warrensbox/terraform-switcher/blob/master/main.go#L430-L435) to load all Terraform configuration files and to extract Terraform version constraints from them (though only the first constraint definition is taken into account). It has lower precedence than version specified on command line, via tfswitchrc, or via .terraform-version though.

For now, I use ENV variable to re-define one of the parameter to get tfswitch work.

Could you please elaborate on your use case since from what you outlined I couldn't figure why you need to apply any quirk to allow tfswitch to do what it's been doing by design apparently since about three years now.
Thanks.

Hello @yermulnik!

Thank you for your response, probably it's just a problem of misconfiguration my zsh environment - I just was misled by the description from README.md, where it was described, that I should use "version.tf" file, but it's just my fault - thanks for clarification and hence I'll close the issue.