Files
gcp_solution_architecture_a…/skills/google-cloud-iac-patterns/references/project-services.md
Jonathan Boniface 5bb22d984e
Some checks failed
validation / verify (push) Failing after 8s
fixed multile issues
2026-10-07 17:33:36 +01:00

34 lines
751 B
Markdown

# Enabling APIs
Enable each API the Elements need, once, and make the first resource of each product depend on it.
- `disable_on_destroy = false` keeps the API on when the configuration is destroyed; other workloads in the project may use it.
```hcl
variable "project_id" {
type = string
description = "Project to deploy into."
}
variable "region" {
type = string
description = "Region for regional resources."
}
locals {
services = [
"run.googleapis.com",
"pubsub.googleapis.com",
"secretmanager.googleapis.com",
]
}
resource "google_project_service" "enabled" {
for_each = toset(local.services)
project = var.project_id
service = each.value
disable_on_destroy = false
}
```