我正在尝试遵循本教程https://learn.hashicorp.com/tutorials/terraform/gke。我对存储库所做的唯一更改是定义了一个项目名称,该名称等于gcloud config get-value project
的结果:
kurtpeek@Kurts-MacBook-Pro ~/g/s/g/k/learn-terraform-provision-gke-cluster (master)> git diff
diff --git a/terraform.tfvars b/terraform.tfvars
index a13174b..4f7eaae 100644
--- a/terraform.tfvars
+++ b/terraform.tfvars
@@ -1,2 +1,2 @@
-project_id = "REPLACE_ME"
+project_id = "kurtpeek-179513"
region = "us-central1"
kurtpeek@Kurts-MacBook-Pro ~/g/s/g/k/learn-terraform-provision-gke-cluster (master)>
gcloud config get-value project
kurtpeek-179513
但是,如果我运行terraform apply
,则会收到以以下错误结尾的日志:
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
google_compute_network.vpc: Creating...
google_compute_network.vpc: Still creating... [10s elapsed]
google_compute_network.vpc: Still creating... [20s elapsed]
google_compute_network.vpc: Creation complete after 23s [id=projects/kurtpeek-179513/global/networks/kurtpeek-179513-vpc]
google_compute_subnetwork.subnet: Creating...
google_compute_subnetwork.subnet: Still creating... [10s elapsed]
google_compute_subnetwork.subnet: Still creating... [20s elapsed]
google_compute_subnetwork.subnet: Creation complete after 23s [id=projects/kurtpeek-179513/regions/us-central1/subnetworks/kurtpeek-179513-subnet]
google_container_cluster.primary: Creating...
google_container_cluster.primary: Still creating... [10s elapsed]
google_container_cluster.primary: Still creating... [20s elapsed]
google_container_cluster.primary: Still creating... [30s elapsed]
google_container_cluster.primary: Still creating... [40s elapsed]
google_container_cluster.primary: Still creating... [50s elapsed]
google_container_cluster.primary: Still creating... [1m0s elapsed]
Error: googleapi: Error 500: Internal error encountered., backendError
on gke.tf line 17, in resource "google_container_cluster" "primary":
17: resource "google_container_cluster" "primary" {
根据https://github.com/hashicorp/terraform/issues/20029,这可能是由于不正确的项目名称引起的,但是我相信我已按照指示设置了该变量(https://learn.hashicorp.com/tutorials/terraform/gke#update-your-terraform-tfvars-file)。知道是什么原因造成的吗? (可从https://github.com/hashicorp/learn-terraform-provision-gke-cluster获得Terraform项目代码)。