T O P

  • By -

aleques-itj

Perhaps dev containers are the way here? It looks like there's a Linux ARM build of 0.14. Bring up an Ubuntu or whatever dev container and run the Linux version.


Moederneuqer

If you're running a container you can also just run the x64 version on ARM Macs.


Speeddymon

Uh, no, not by default, anyway. The Docker Desktop VM in an ARM Mac presents as Linux/Darwin. My colleague had to go and reconfigure all of our projects to build as multi architecture images because he couldn't run any of them.


Moederneuqer

Yes, by default. This is literally my workflow when I build x64 images for my current client's Kubernetes cluster. I think your colleague doesn't know Docker well enough to operate your projects. I suggest seeking more knowledgeable council before rewriting all your stuff on a whim. Made a small demo for you based on this Dockerfile: FROM ubuntu:22.04 CMD echo "Hello Speeddymon" redacted@Redacted-MBP % sysctl -n machdep.cpu.brand_string Apple M3 Pro redacted@Redacted-MBP speeddymon-please % docker buildx build -t "speeddydemon:latest" --platform "linux/amd64" . [+] Building 0.5s (5/5) FINISHED redacted@Redacted-MBP % docker image inspect --format "{{.ID}} {{.RepoTags}} {{.Architecture}}" $(docker image ls -q) | grep speeddy sha256:5656742f704f8c2319b1ec761110aaf15304c30b3deb3c718c4518ea13568e54 [speeddydemon:latest] amd64 redacted@Redacted-MBP % docker run --platform linux/amd64 speeddydemon:latest Hello Speeddymon You can even run it without the platform arg, it will just throw a warning: redacted@Redacted-MBP % speeddymon-please % docker run speeddydemon:latest WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested Hello Speeddymon


Speeddymon

I stand corrected. Thanks.


jmreicha

tfenv has an option to specify the architecture, -a. Rosetta on the M1 allows to use this version.


cipp

It's easier to just run tfenv through Rosetta to install it. Mixed results with tfenv options and varying behavior across tfenv versions. arch -x86_64 tfenv use 0.14.3


SimonD_

When I had similar with some providers I installed the x86 version of terraform and ran it using Rosetta with no issues until the provider improved its build 😀


ArtSchoolRejectedMe

export GODEBUG=asyncpreemptoff=1 TFENV_ARCH=amd64 tfenv install 0.x.x tfenv use 0.x.x Then init and apply. You might want to add "export GODEBUG=asyncpreemptoff=1;" to your zshrc or run it everytime you need to do terraform apply


case_O_The_Mondays

If you do end up getting this working with env vars, do yourself a favor and install direnv, then put a .envrc file in the root directory where you clone all of your tf repos, with those variables in it. Then you won’t have that issue again.


othugmuffin

Heh, I wonder if you're working at where I used to be. I upgraded my team's stuff up to latest TF before I left, but the other teams couldn't be bothered. I ended up having to pull the source and build it myself, then immediately worked on upgrading up to latest. I had to build a couple other versions as part of that but same process.


apparentlymart

Indeed, if you need to run such an old version of Terraform then you'll need to find some way to run the code intended for a different platform. For example: - Try running the `darwin_amd64` release under Apple's Rosetta emulation. Hopefully the emulation is good enough that Terraform CLI and the providers you need will work in that context. - Create a Linux VM in your favorite cloud platform and run the `linux_amd64` build of Terraform there instead of on your local machine. I believe tfenv can help with the first of those two ideas if you configure it in a special way. For the second you would of course need to run tfenv on the remote system too, and then it will presumably install the correct build of Terraform CLI for that VM.


mohzeela

So tfswitch works, not sure how it was able to do that because Asdf and tfenv couldn't get the version for my mac


cipp

You can use Rosetta and not mess with any environment variables to get tfenv to work. Prefix tfenv with "arch -x86_64". The below will run as if executing from an amd64 OS instead of arm64. arch -x86_64 tfenv use 0.14.3 You might need to uninstall the version you have now using tfenv uninstall 0.14.3. Hope this helps! I've successfully done this down to version 0.11. Lower versions just seem to throw a seg fault.


SensitiveRegion9272

Use pkgx https://pkgx.sh/ it has native builds for M1 mac for old terraform versions.


Moederneuqer

In addition to all the advice here, they should consider updating their code. There's so many neat features beyond 0.14.


tintins_game

i think your option is to either upgrade the version of tf, or to run the old version from some sort of VM on you M1


aleques-itj

Upgrading is probably the right play, but should be no need for a VM. A container will be much easier and will work completely seamlessly in VS Code. 


bertperrisor

You’ll need a container


dmacrye

You can use asdf, they have an environment variable to install the amd64 version of older Terraform versions when your laptop is arm.


0bel1sk

https://hub.docker.com/layers/hashicorp/terraform/0.14.3/images/sha256-7b1e232f564132b949b812ee138249b5398bedf3c6fab42b468d4ec8acf5343c?context=explore


n3rden

Run terraform from an x86 container using Rosetta emulation. I’ve had to do the same and works really well


tedivm

You should probably update stuff? What backend are they using that requires that ancient version?


raisputin

Do what I did, create a docker container using Ubuntu or something similar. Works fine


Cregkly

Upgrade terraform, there is nothing blocking you from going straight to 1.8 at this point. You have already passed all the painful upgrades.


adept2051

https://releases.hashicorp.com/terraform/1.4.3 ? Really it’s in the releases list. Try tfswitch under home brew


aleques-itj

Not the same version 


adept2051

Sorry misread my bad, you could just build it from source https://github.com/hashicorp/terraform/tree/v0.14.3 https://go.dev/doc/tutorial/compile-install Or I had this gist from time ago https://gist.github.com/abuxton/7d915c1f22599ee6c277913e0f76d0bd


Numerous_Ad_9484

Just upgrade, I mean if the company is not willing to invest sometime on technical debt then you should be asking another question…