Sample Terraform script that can be used to enable the required APIs at each project level for Google Cloud monitoring
Use this sample Terraform script to enable the required APIs for each project. This Terraform script helps you enable all the required APIs for multiple projects in a single deployment.
- Main.tf
- provider "google" {
- project = "base project id"
- } module "project-services" {
- source = "terraform-google-modules/project-factory/google//modules/project_services"
- for_each=var.project_id_map
- project_id = "${each.value.project_id}"
- activate_apis = [
- "compute.googleapis.com",
- "cloudfunctions.googleapis.com",
- "dataproc.googleapis.com",
- "redis.googleapis.com",
- "container.googleapis.com",
- "spanner.googleapis.com",
- "appengine.googleapis.com",
- "pubsub.googleapis.com",
- "composer.googleapis.com",
- "monitoring.googleapis.com",
- "compute.googleapis.com",
- "dataflow.googleapis.com",
- "run.googleapis.com",
- "file.googleapis.com",
- "cloudkms.googleapis.com",
- "dns.googleapis.com",
- "cloudbilling.googleapis.com",
- "cloudresourcemanager.googleapis.com",
- "cloudasset.googleapis.com",
- "servicenetworking.googleapis.com",
- "appengine.googleapis.com",
- "container.googleapis.com",
- "sqladmin.googleapis.com",
- "cloudkms.googleapis.com"
- ]
- }
- variables.tf
- variable "project_id_map" {
- type = map(object({
- project_id = string
- }))
- default = {
- "Projectid_1" = {
- project_id = "project_1_id"
- }
- "Projectid_2" = {
- project_id = "project_2_id"
- }
- }
- }