[英]GCP Cloud Build and Terraform integration
I am running Terraform using Cloud Build.我正在使用 Cloud Build 运行 Terraform。
step {
name = "hashicorp/terraform:1.0.1"
args = ["init"]
dir = env/dev
}
step {
name = "hashicorp/terraform:1.0.1"
args = ["plan"]
dir = env/dev
}
step {
name = "hashicorp/terraform:1.0.1"
args = ["apply", "-auto-approve"]
dir = env/dev
}
in my terraform code there is a local-exec command which runs some Linux commands and one gcloud command.在我的 terraform 代码中有一个 local-exec 命令,它运行一些 Linux 命令和一个 gcloud 命令。
resource "null_resource" "gcloud" {
provisioner "local-exec" {
command = <<EOT
.
some Linux commads
.
gcloud pubsub topics list
EOT
}
}
after Terraform Apply, it gives me:在 Terraform Apply 之后,它给了我:
exit status 127. Output: /bin/sh: gcloud: not found
to solve this issue I used gcloud module:为了解决这个问题,我使用了 gcloud 模块:
module "gcloud" {
source = "terraform-google-modules/gcloud/google"
version = "3.1.0"
create_cmd_endpoint = "gcloud"
create_cmd_body = "version"
destroy_cmd_body = "gcloud"
destroy_cmd_body = "version"
}
now I have two errors:现在我有两个错误:
[7:47 p.m., 2022-11-13] Milad: exit status 127. Output: /bin/sh: curl: not found
[7:47 p.m., 2022-11-13] Milad: exit status 127. Output: /bin/sh: gcloud: not found
Any help would be appreciated.任何帮助,将不胜感激。
The error that you have mentioned above seems to be due to the “gcloud” module not being incorporated properly and thus the command referencing the sub command results in this kind of error.您上面提到的错误似乎是由于“gcloud”模块未正确合并,因此引用子命令的命令导致此类错误。 The “gcloud” module execution should make sure that “gcloud” is decompressed and set up in the proper order during the setup.
“gcloud”模块执行应确保“gcloud”在安装过程中以正确的顺序解压缩和设置。
I would recommend you try the latest version of terraform registry which seems to address this issue.我建议您尝试最新版本的 terraform 注册表,它似乎可以解决此问题。
Also check these similar examples:还要检查这些类似的例子:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.