首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在我的Apple Silicon Macbook Pro for the Google Provider上运行‘`terraform’?

如何在我的Apple Silicon Macbook Pro for the Google Provider上运行‘`terraform’?
EN

Stack Overflow用户
提问于 2021-02-20 01:00:11
回答 1查看 4.6K关注 0票数 1

当我在我的Apple Silicon macbook pro上为我的Google Cloud平台项目运行terraform init时,我得到了这个错误。

代码语言:javascript
复制
Provider registry.terraform.io/hashicorp/google v3.57.0 does not have a package available for your current platform, darwin_arm64.

我该如何解决这个问题呢?我原以为Rosetta2仿真器会选中此框,但可惜...

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-02-20 01:00:11

大多数提供商已经在较新版本中提供了包。您可以通过:terraform init -upgrade更新提供商,如果您不接受此路由,或者它不能解决问题,请查看下面的答案。

从头开始构建Terraform的GCP提供者!我修改了此演练。https://github.com/hashicorp/terraform/issues/27257#issuecomment-754777716

代码语言:javascript
复制
brew install --build-from-source terraform

这也会安装Golang (在这篇文章中看起来还不错)

代码语言:javascript
复制
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

下面的目录可能还不存在,所以让我们创建它并复制我们刚刚构建的二进制文件。

代码语言:javascript
复制
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

请注意,如果您还没有定义${GOPATH},那么您的golang安装将位于${HOME}/go。如果您这样做了,那么修改上面的命令来说明您的新构建二进制文件的位置。

代码语言:javascript
复制
cp ${GOPATH}/bin/terraform-provider-google ${HOME}/.terraform.d/plugins/registry.terraform.io/hashicorp/google/3.22.0/darwin_arm64

回到我的项目之后,瞧!

代码语言:javascript
复制
➜ 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
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66281882

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档