Closed jeremad closed 4 years ago
Well, looking at make a PR to do this, I realized that this API used to exist. I didn't find why it was removed, though
https://www.terraform.io/docs/providers/google/guides/version_3_upgrade.html#resource-google_project_services https://registry.terraform.io/modules/terraform-google-modules/project-factory/google/3.3.0/submodules/project_services
OK I found out what I needed to know, I'll use the module. I can close this.
Actually the module cannot be used with multiple projects programmatically because of https://github.com/hashicorp/terraform/issues/17519.
So it would still be nice to have a non-authoritative version of google_project_services
Hi there! It seems like a resource-level for_each
on google_project_service
would do what you need - is that right?
Let me provide a little more:
variable "services" {
type = list(string)
}
resource "google_project_service" "services" {
for_each = toset(var.services)
project = "my-project"
service = each.value
}
And then you can set the variable in a tf.vars file or however you prefer to set variables.
Is that helpful?
The problem is when you need to iterate over services and projects!
I managed to make it work with setproduct
however I am not too satified with the result, and since the GCP APIs supports it, I figured it would be a nice feature. However I understand that this is just a nice to have, and there is probably some more important stuff to work on.
Ah yeah, setproduct
is a good solution for that. :)
Behind the scenes we do support the GCP API service enablement batch mode. I'm going to close this issue since the setproduct
solution is the best one right now and should get you the relatively-low request volume you're looking for.
OK, I understand. Thank you for you support anyways ! :+1:
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!
Community Note
Description
The
google_project_service
ressource allows to enable a service API on a project. When manipulating multiple projects, it would be nice to provide a way to enable multiple service APIs.It is easy to loop around APIs when manipulating one or two projects, however for N projects this does not scale easily.
New or Affected Resource(s)
A new resource that will enable multiple service APIs, using the batchEnable endpoint
Potential Terraform Configuration
References
https://cloud.google.com/service-usage/docs/reference/rest/v1/services/batchEnable