简体   繁体   中英

Terraform: Google cloud. Why cannot I create a new project without having an organisation?

I cannot understand the rationale behind prohibiting a user that has no organisation to create new google cloud projects with terraform. Indeed, if I use gcloud , I am able to create new projects and I can also do that using the web console.

As mentioned in the documentation :

The user or service account that is running Terraform when creating a google_project resource must have roles/resourcemanager.projectCreator on the specified organization.

The problem with roles/resourcemanager.projectCreator is, that it's an organization role - not project role. Therefore without organization one cannot get this role.

The ability to do it using the console but not through the official Terraform way is strange indeed.

But, it seems that there's a workaround, that will just require you to provide billing account and will enable you creating new project - by using the project module of Google's official cloud-foundation-fabric .

Basic example:

module "project" {
  source          = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/project?ref=v19.0.0"
  billing_account = "your-billing-account"
  name            = "your-project-name"
  services = [
    "container.googleapis.com",
  ]
}

It might take some time (took me about 3.5 minutes), but did the job without creating organization.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM