Terraform with Multipass on Apple M1

Hi

As a disclaimer, I have tried to use Multipass in a way that it might not have been intended for, so apologies if I have missed the point.

I want to use the Multipass shell to test Terraform in Linux, as a complement to testing in macOS on my M1 laptop. To that end, I started the shell, and tried to install Terraform via apt. That didn’t work as the only supported architecture is amd64, as explained here:

https://www.terraform.io/cli/install/apt

And:

$ dpkg --print-architecture
arm64

I then tried downloading the zip, but that didn’t work either, as illustrated below.

My question, then, is: can I use Terraform in the way I want here?

Thanks

Nathan

cd Home/git/terraform-sdwan/vmware/
ubuntu@primary:~/Home/git/terraform-sdwan/vmware$ sudo apt install unzip -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
unzip is already the newest version (6.0-25ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
ubuntu@primary:~/Home/git/terraform-sdwan/vmware$ rm terraform
ubuntu@primary:~/Home/git/terraform-sdwan/vmware$ curl https://releases.hashicorp.com/terraform/1.1.9/terraform_1.1.9_darwin_amd64.zip --output terraform_1.1.9_darwin_amd64.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19.7M  100 19.7M    0     0  3900k      0  0:00:05  0:00:05 --:--:-- 4227k
ubuntu@primary:~/Home/git/terraform-sdwan/vmware$ unzip terraform_1.1.9_darwin_amd64.zip
Archive:  terraform_1.1.9_darwin_amd64.zip
  inflating: terraform               
ubuntu@primary:~/Home/git/terraform-sdwan/vmware$ ./terraform
-bash: ./terraform: cannot execute binary file: Exec format error
ubuntu@primary:~/Home/git/terraform-sdwan/vmware$ rm terraform
ubuntu@primary:~/Home/git/terraform-sdwan/vmware$ curl https://releases.hashicorp.com/terraform/1.1.9/terraform_1.1.9_darwin_arm64.zip --output terraform_1.1.9_darwin_arm64.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 18.9M  100 18.9M    0     0  4091k      0  0:00:04  0:00:04 --:--:-- 4300k
ubuntu@primary:~/Home/git/terraform-sdwan/vmware$ unzip terraform_1.1.9_darwin_arm64.zip
Archive:  terraform_1.1.9_darwin_arm64.zip
  inflating: terraform               
ubuntu@primary:~/Home/git/terraform-sdwan/vmware$ ./terraform
-bash: ./terraform: cannot execute binary file: Exec format error
ubuntu@primary:~/Home/git/terraform-sdwan/vmware$ which ./terraform
./terraform
ubuntu@primary:~/Home/git/terraform-sdwan/vmware$ dpkg --print-architecture
arm64
ubuntu@primary:~/Home/git/terraform-sdwan/vmware$ 

Hi @nathanto, so you’ve mixed a couple of things here. First, yeah you can’t run amd64 instances in Multipass on ARM (because it’s slow).

But second, you’ve tried to run macOS binaries inside Linux, both amd64 (which wouldn’t work, even if they were Linux binaries), and amr64 (which would work if they were).

But according to the docs you’ve pointed at, there are binaries for other architectures for Ubuntu as well:

So “such as amd64”, not that it’s the only one.

If you follow the steps exactly, you should be able to run Terraform under Multipass just fine. But. Since there are macOS binaries, wouldn’t it be better to run them natively? (NB: I’m quite ignorant as to what Terraform is).

1 Like

Thank you :slightly_smiling_face:

This works:

rm terraform
curl https://releases.hashicorp.com/terraform/1.1.9/terraform_1.1.9_linux_arm64.zip --output terraform_1.1.9_linux_arm64.zip
unzip terraform_1.1.9_linux_arm64.zip
./terraform

Note that Terraform is an IaC tool, which is built around the idea of “providers”. In this case, there is a deprecated provider in some code that I have inherited, and that deprecated provider is not available on an M1 macOS machine. So, to test, I am using a Linux environment, but I mixed my platform metaphors, as it were.

1 Like