# Secret Manager Terraform creates the secret and who may read it. The value is added outside Terraform, so it never enters the state or the repository. - `replication` is required: `auto {}` for Google-managed locations, or `user_managed` with one `replicas` block per location. - Grant `roles/secretmanager.secretAccessor` on the secret, to the one identity that reads it. - Never write a `google_secret_manager_secret_version` with the value in the configuration. ```hcl variable "project_id" { type = string description = "Project to deploy into." } variable "region" { type = string description = "Region for regional resources." } resource "google_service_account" "reader" { project = var.project_id account_id = "api-key-reader" display_name = "Reads the API key" } resource "google_secret_manager_secret" "api_key" { project = var.project_id secret_id = "partner-api-key" replication { user_managed { replicas { location = var.region } } } } resource "google_secret_manager_secret_iam_member" "reader_reads_api_key" { project = var.project_id secret_id = google_secret_manager_secret.api_key.secret_id role = "roles/secretmanager.secretAccessor" member = google_service_account.reader.member } ```