Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tfenv install fails if Terraform is already installed, but Hashicorp's CDN is unavailable #395

Closed
don-code opened this issue May 17, 2023 · 0 comments

Comments

@don-code
Copy link

The releases.hashicorp.com site was down briefly this morning. We pre-bake needed Terraform versions into our CI/CD executors, but still run a tfenv install ... command to make local dev easier.

Since Hashicorp releases are immutable, I'd expect that if a given revision of Terraform is already installed, tfenv wouldn't have any need to reach out to their CDN. Instead, it would detect that this version is already installed, and pass.

If releases.hashicorp.com is down, and a requested version of Terraform is already installed, tfenv will fail instead:

bash-5.2# tfenv list
  1.4.6
No default set. Set with 'tfenv use <version>'

bash-5.2# tfenv install 1.4.6
curl: (7) Failed to connect to releases.hashicorp.com port 443 after 0 ms: Couldn't connect to server
Failed to download remote versions from https://releases.hashicorp.com/terraform/
No versions matching '1.4.6' found in remote
bash-5.2# echo $?
1

Here's a test case with Docker to reproduce:

# on local machine
$ docker run -it --rm bash

# inside the container - set up the environment
$ apk add curl git
$ git clone --depth=1 https://github.com/tfutils/tfenv.git ~/.tfenv
$ export PATH=~/.tfenv/bin:$PATH

# install Terraform
$ tfenv install 1.4.6

# make releases.hashicorp.com resolve to localhost, to fake an outage
$ echo "127.0.0.1 releases.hashicorp.com" > /etc/hosts

# try to install again - this step should succeed, but currently fails
$ tfenv install 1.4.6
Zordrak added a commit that referenced this issue Dec 19, 2023
Do not check the release list if a Terraform is already installed (fixes #395)
Zordrak added a commit that referenced this issue Dec 19, 2023
Revert "Do not check the release list if a Terraform is already installed (fixes #395)"
bkzhn pushed a commit to bkzhn/tfenv that referenced this issue Jan 14, 2024
 tfutils#395)

Today, tfenv checks the Terraform release list when running
`tfenv install`, even if the requested Terraform is already
installed. This fixes an issue where a script containing
`tfenv install` becomes inoperable even if Terraform is installed,
but releases.hashicorp.com is down.

See tfutils#395 for more information.
bkzhn pushed a commit to bkzhn/tfenv that referenced this issue Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant