我正在关注https://cloud.google.com/community/tutorials/managing-gcp-projects-with-terraform上的教程
基本上它归结为创建一个terraform-admin
默认项目,该项目有权成为roles/resourcemanager.projectCreator
$ gcloud organizations get-iam-policy $TF_VAR_org_id
bindings:
...snipped...
- members:
- domain:raverun.com
- serviceAccount:terraform@terraform-admin.iam.gserviceaccount.com
role: roles/resourcemanager.projectCreator
我不会在project.tf
这里复制文件,但主要项目是:
provider "google" {
...snipped...
}
resource "google_project" "proj" {
...snipped...
project_id = "tf-foobar"
}
resource "google_project_services" "svcs" {
...snipped...
}
跑步前terraform apply
$ gcloud projects list
PROJECT_ID NAME PROJECT_NUMBER
terraform-admin terraform-admin 300000000000
运行后terraform apply
$ terraform apply
...snipped...
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
Outputs:
project_id = tf-foobar
$ gcloud projects list
PROJECT_ID NAME PROJECT_NUMBER
terraform-admin terraform-admin 300000000000
我的问题是为什么新项目tf-foobar
没有出现?