leg100/otf

use terraform version from local files

Closed this issue · 3 comments

I don't know how you feel about deviating from TFC and improve on things.

One thing I've struggled with historically is the fact that the version on a workspace is separate from the code.

So, building on #608, I was thinking an alternative would be to retrieve the used to version from one of the following sources:

  • Read from the TF by resolving terraform.required_version and picking the latest possible version.
  • Read from .terraform-version (for tfenv)
  • Read from .tool-versions (for asdf)

Personally my vote goes for using the terraform block code, as it's right there within the code, and seems like a reasonable thing to expect. You set your terraform version requirements in the official way, and that's what gets used.

Alternatively, these can be separate options that can be set separately.

leg100 commented

@hoshsadiq Seems reasonable. I'm trying to think of reasons why this is a bad idea but I can't think of any.

@pat-s Since you raised #608, can you give your view on this?

In any case, I think the priority is to implement #608 first.

And there is the work to support for the upcoming first production release of OpenTofu, which again would take priority.

pat-s commented

There can surely be various approaches to tackle this.
It depends a bit how flexible @leg100 wants it to be.

I could think of

  • a UI option which takes precedence if set explicitly
    • reads a version defined in a file (if existent) (as suggested by @hoshsadiq)
    • resolves to latest dynamically if both of the above are unset

I guess overall there will always be a discrepancy between what OTF uses (and what is set in the workspace there) and what users have installed on their local machines. Choosing an arbitrary version is "easy" for OTF but not so for local installs as most users just go with a dynamic package manager install which auto-updates every few days/weeks and usually only have one version present.

There could optionally be a warning if the TF version of a local execution does not match the one set/expected in the workspace.

Archiving repo.