rek*_*a18 1 google-cloud-platform terraform apple-m1
当我terraform init在 Apple Silicon macbook pro 上运行我的 Google Cloud Platform 项目时,出现此错误。
Provider registry.terraform.io/hashicorp/google v3.57.0 does not have a package available for your current platform, darwin_arm64.
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?我以为 Rosetta2 模拟器会选中这个框,但唉...
arv*_*tal 29
使用tfenv包从头开始构建Terraform,它可以构建适应平台架构的特定版本。
我运行以下命令来安装在我的 M1 Macbook 下运行的版本(本例中为版本 1.3.3):
brew uninstall terraform
brew install tfenv
TFENV_ARCH=amd64 tfenv install 1.3.3
tfenv use 1.3.3
Run Code Online (Sandbox Code Playgroud)
kis*_*HoR 11
Thanks for this repo: https://github.com/kreuzwerker/m1-terraform-provider-helper. This will remove the overhead of building and compiling from us.
Usage:
brew install kreuzwerker/taps/m1-terraform-provider-helper
m1-terraform-provider-helper activate # (In case you have not activated the helper)
m1-terraform-provider-helper install hashicorp/template -v v2.2.0 # Install and compile
Run Code Online (Sandbox Code Playgroud)
This will compile the provider for our arm_64 in the location:
~/.terraform.d/plugins/registry.terraform.io/hashicorp/template/2.2.0/darwin_arm64
For this to be working, these are my findings:-
.terraform.lock.hcl
m1-terraform-provider-helper lockfile upgrade which finds and updates these checksumsGo ahead now !!!
大多数供应商已经提供了更新版本的软件包。您可以通过以下方式更新提供程序:
terraform init -upgrade
如果您不接受此路线或无法解决问题,请查看以下答案。
从头开始构建 Terraform 的 GCP 提供程序!我修改了这个演练。https://github.com/hashicorp/terraform/issues/27257#issuecomment-754777716
brew install --build-from-source terraform
Run Code Online (Sandbox Code Playgroud)
这也将安装 Golang(并且在这篇文章中似乎正在运行)
git clone https://github.com/hashicorp/terraform-provider-google.git
cd terraform-provider-google
git checkout v3.22.0
go get -d github.com/pavius/impi/cmd/impi
make tools
make build
Run Code Online (Sandbox Code Playgroud)
下面的目录可能不存在,所以让我们创建它并复制我们刚刚构建的二进制文件。
mkdir -p ${HOME}/.terraform.d/plugins/registry.terraform.io/hashicorp/google/3.22.0/darwin_arm64
cp ${HOME}/go/bin/terraform-provider-google ${HOME}/.terraform.d/plugins/registry.terraform.io/hashicorp/google/3.22.0/darwin_arm64
Run Code Online (Sandbox Code Playgroud)
请注意,${HOME}/go如果您还没有${GOPATH}定义,这是您的 golang 安装所在的位置。如果这样做,请修改上述命令以说明新构建二进制文件的位置。
cp ${GOPATH}/bin/terraform-provider-google ${HOME}/.terraform.d/plugins/registry.terraform.io/hashicorp/google/3.22.0/darwin_arm64
Run Code Online (Sandbox Code Playgroud)
回到我的项目后,瞧!
? terraform init
Initializing the backend...
Initializing provider plugins...
- Finding latest version of hashicorp/google...
- Installing hashicorp/google v3.22.0...
- Installed hashicorp/google v3.22.0 (unauthenticated)
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
Run Code Online (Sandbox Code Playgroud)
好的。所以,我“找到”了我的问题的答案。您很可能像我一样使用如下所示的 main.tf 配置:
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "3.22.0"
}
}
}
provider "google" {
credentials = file("foo.json")
project = "foo"
region = "us-central1"
zone = "us-central1-c"
}
resource "google_compute_network" "vpc_network" {
name = "terraform-network"
}
Run Code Online (Sandbox Code Playgroud)
好吧,删除这部分,你不需要它:
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "3.22.0"
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果仍然无法正常工作,请重新安装 TERRAFORM 并从项目的新目录开始。
希望这可以帮助某人。
顺便说一句,我的 Terraform 版本
darwin_arm64 上的Terraform v1.1.3
+ 提供商registry.terraform.io/hashicorp/google v4.6.0
| 归档时间: |
|
| 查看次数: |
2331 次 |
| 最近记录: |