Skip to content

Search parent directories for Terraform version #218

@joe-a-t

Description

@joe-a-t

Is your feature request related to a problem? Please describe.

At my company, we have a bunch of Terraform repos. Within each of those repos, we have hundreds of different Terraform root modules. Currently, we have a .terraform-version at the root of each of those repos and use tfenv to search the parent directories looking for those .terraform-version files and switch the version automatically.

We would like to switch to use tfswitch because it is more performant than tfenv with certain IDEs and Terraform auto-formatting plugins, but it would currently require us to go from specifying the Terraform version in a handful of spots at the root of each repo, to specifying it thousands of times in each of our Terraform root modules.

Describe the solution you'd like

Instead of the current behavior of only looking in the current directory for a file that specifies the Terraform version, we would like for tfswitch to automatically search upwards through the parent directories until it finds a .terraform-version (or other) file and switch based on that, or if no match is found, drop into the interactive Select Terraform version prompt.

Additional context

The issue is not simply with adjusting the hooks that are provided by https://github.com/warrensbox/terraform-switcher#automation, even explicitly running tfswitch does not consider the .terraform-version file in a parent directory. Whenever this feature is implemented, we should also adjust the hook recommendations, maybe to automatically trigger any time that the current directory has .tf files?

Metadata

Metadata

Assignees

Labels

new featureNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions