[英]GCP Cloud Build and Terraform integration
我正在使用 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
}
在我的 terraform 代碼中有一個 local-exec 命令,它運行一些 Linux 命令和一個 gcloud 命令。
resource "null_resource" "gcloud" {
provisioner "local-exec" {
command = <<EOT
.
some Linux commads
.
gcloud pubsub topics list
EOT
}
}
在 Terraform Apply 之后,它給了我:
exit status 127. Output: /bin/sh: gcloud: not found
為了解決這個問題,我使用了 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"
}
現在我有兩個錯誤:
[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
任何幫助,將不勝感激。
您上面提到的錯誤似乎是由於“gcloud”模塊未正確合並,因此引用子命令的命令導致此類錯誤。 “gcloud”模塊執行應確保“gcloud”在安裝過程中以正確的順序解壓縮和設置。
我建議您嘗試最新版本的 terraform 注冊表,它似乎可以解決此問題。
還要檢查這些類似的例子:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.