terraform-switcher icon indicating copy to clipboard operation
terraform-switcher copied to clipboard

Handle multiple terraform architecture (arm64/amd64) for the same version

Open alex-ikse opened this issue 2 years ago • 4 comments

We use multiple version of terraform in arch amd64 and arm64.

With recent terraform stacks, no problem, we can run all terraform/provider as arm64 binaries, but for older stacks, that use unmaintained provider (available only as amd64), we need to run terraform as amd64 (via rosetta 2) ...

In this last case, tfswitch don't download terraform again because the version already exist in ~/.terraform.versions ... but with bad arch.

The proposed patch add the architecture to the terraform binary name to be able to have an arm64 and amd64 version of the same terraform version and let the user choose a specific architecture for terraform (with the new -a / --arch parameter).

alex-ikse avatar Apr 08 '22 14:04 alex-ikse

Hi @alex-ikse, could you elaborate on the problem and scenarios where you need to override runtime.GOARCH? Wouldn't you then need a machine running the given architecture to execute tfswitch? I don't think I'm following. Might be good to file an associated issue as well.

jukie avatar May 24 '22 01:05 jukie

tfenv handles with TFENV_ARCH=amd64 which downloads the amd64 version (instead of arm64 specified by runtime.GOARCH). The amd64 version of Terraform is run via Rosetta for compatibility with providers that haven't been updated to arm64 yet.

davidvasandani avatar Oct 26 '22 05:10 davidvasandani

I am looking for the options to switch between native darwin_arm64 and darwin_amd64 as well. I have a number of providers that don't have native darwin_arm64 support yet.

kneufeld-pbp avatar Mar 12 '23 23:03 kneufeld-pbp

With recent terraform stacks, no problem, we can run all terraform/provider as arm64 binaries, but for older stacks, that use unmaintained provider (available only as amd64), we need to run terraform as amd64 (via rosetta 2) ...

Is this still a matter? If it is, then a) what would be the version constraint for "older stacks" and b) should this be restricted to only specific OS family, arch, and TF versions? Especially given that this covers exactly specific OS family, arch and TF versions... I don't see a use case for an arbitrary e.g. Linux of amd64 arch to get arm64 version of Terraform along with getting it linked as a default terraform binary.

ps: overall the idea of using tfswitch as "terraform getter" looks interesting... apart from auto-linking binary with incompatible ABI into a default location. Maybe it's worth of a complimentary cmdline option like --force-install? 🤔

yermulnik avatar Apr 11 '23 23:04 yermulnik

Closing as stale. Please update this thread if this is still a case and we'll look into it again. Thanks.

yermulnik avatar Jun 05 '24 10:06 yermulnik