Giter Club home page Giter Club logo

Comments (6)

kmoe avatar kmoe commented on August 25, 2024

also possibly https://warrensbox.github.io/terraform-switcher/

from terraform-exec.

kmoe avatar kmoe commented on August 25, 2024

See hashicorp/terraform-ls#128 for unexpected behaviour cased by using a wrapper script to set appropriate env vars.

from terraform-exec.

paultyng avatar paultyng commented on August 25, 2024

At least warn or let consumers know if these tools are being used, even if we aren't going to handle it.

from terraform-exec.

kmoe avatar kmoe commented on August 25, 2024

Another one: https://github.com/Yleisradio/homebrew-terraforms

from terraform-exec.

kmoe avatar kmoe commented on August 25, 2024

Results of investigation. Branch tfenv-etc contains some Dockerfiles for experimenting with these utilities in a clean environment (except homebrew-terraforms, which is only available for macOS).

tfenv

Installing tfenv adds a shell script named terraform to the $PATH, so which terraform resolves to this script. This script checks whether $TFENV_ROOT/version is set, and errors if not. An error will also be logged if the user has not selected a version with tfenv use.

Currently, this means that any use of tfinstall.LookPath() will error and not fall through to the next ExecPathFinder, because it assumes that if it finds a terraform binary then it must report terraform version properly. Recommend relaxing this and will open PR to do so.

terraform on path is now a shell script: yes
Terraform version may depend on working directory: yes

terraform-switcher

Installing a Terraform version via tfswitch replaces any existing Terraform binary with a symlink. This is only done when installing a new version of Terraform, so unlike tfenv there is no risk of the binary or script at which terraform not pointing to Terraform itself.

terraform on path is now a shell script: no
Terraform version may depend on working directory: yes

homebrew-terraforms

The most conservative of the three helpers, this simply provides a chtf utility which allows the user to install and (with caching) switch between various versions of Terraform via the brew package manager. It therefore has no more impact on tfexec than brew itself.

terraform on path is now a shell script: no
Terraform version may depend on working directory: no

Conclusion & recommendations

  • tfinstall.LookPath() - do not error out when an executable named terraform is found but terraform version does not return reasonable output; fall through to the next method instead.
  • Add note to README warning users of helpers that if the terraform on their path resolves to a different version depending on working directory, this will also be true of the Terraform executable located by tfinstall.LookPath().
  • If necessary, open separate issue to deal with env passthrough / direnv issue as described in hashicorp/terraform-ls#128 (comment) (follow up with @radeksimko).

from terraform-exec.

kvendingoldo avatar kvendingoldo commented on August 25, 2024

btw. you can also use tenv that support Terraform as well as OpenTofu (and Terragrunt :) ) in one tool. It allow you to simplify version management and can do much more, than tfswitch.

from terraform-exec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.