How to create a Google Cloud project with service management API enabled?

心不动则不痛 提交于 2019-12-10 17:51:41

问题


We're deploying our software on behalf (OAuth2) of users on Google Cloud. We've managed to automate most of it, but there's one bit that's missing.

  1. Creating the project is done with https://godoc.org/google.golang.org/api/cloudresourcemanager/v1#ProjectsService.Create
  2. Enabling the required APIs (compute, storage, etc) is done with google.golang.org/api/servicemanagement/v1#ServicesService.Enable (can't post as full link thanks to the very bright SO limitations)
  3. Creating the instance is done with google.golang.org/api/compute/v1#InstancesService.Insert

The missing bit is between step 1 and step 2: in order to make use of the Service Management API to enable the needed APIs, we need the Service Management API itself to be enabled on the project (how ironic). I'm hoping there must be a way to create a project with some APIs enabled from the start, maybe with cloudresourcemanager, or maybe with https://godoc.org/google.golang.org/api/deploymentmanager/v2, but I haven't found it so far.

So, to restate: does anyone know if it's possible (in Go) to create a Google Cloud project with some specific Google Cloud APIs enabled right on/after creation?


回答1:


Use the Service Usage API: https://cloud.google.com/service-usage/docs/reference/rest/

(updated)




回答2:


The Google Cloud Resource Manager API is very limited in what it will allow you to do.

while it does have a projects.update method it does not support enabling APIs. Your going to have to manually edit the project.



来源:https://stackoverflow.com/questions/43482969/how-to-create-a-google-cloud-project-with-service-management-api-enabled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!