Comments (6)
also possibly https://warrensbox.github.io/terraform-switcher/
from terraform-exec.
See hashicorp/terraform-ls#128 for unexpected behaviour cased by using a wrapper script to set appropriate env vars.
from terraform-exec.
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.
Another one: https://github.com/Yleisradio/homebrew-terraforms
from terraform-exec.
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 namedterraform
is found butterraform 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 bytfinstall.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.
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)
- Support for `terraform state show`
- Pass through environment variables when `SetEnv()` is used
- TF_WORKSPACE not parsed for empty Cloud block HOT 2
- follow terraform apply HOT 7
- Add functions that run Terraform commands with `-json` flag HOT 1
- Init -migrate-state HOT 6
- stderr is empty HOT 5
- Support `state list` HOT 2
- Does this library provide a way to gracefully shutdown
- Use terraform-json StateOutput for Output method return value
- Consider supporting `terraform test` HOT 1
- Failure to unmarshall checks list with Terraform 1.6
- Init error return
- Support -generate-config-out option for terraform plan HOT 1
- Consider adding show option to configure JSON decoding
- Make UseJSONNumber the default
- Unable to set log level without writing to file HOT 1
- Passing In Variables At Runtime
- Terraform Apply Command Looking For AZ CLI
- Support `terraform init` JSON output (coming soon)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-exec.