Files
solution_architecture_agent/skills/google-cloud-iac-patterns/references/iam.md
Jonathan Boniface c84dbdea20 feat: the solution architecture agent on the shared Execution engine
The reference agent's subject, cloud solution architecture, as an agent in
the operating model agent's pattern: the Execution engine (from
orchestration_engine) and one Workflow in app/solution_architecture,
built for the settings and provider bundle by assembly.workflow_for.

Copied from gcp_solution_architecture_agent at 8b397cd without its own
engine: its role files, Skills, provider bundle, ADRs, vocabulary, scripts
and evaluation datasets. The image takes the engine from a named build
context and installs Terraform. It is called through the Orchestration
engine, and its files are what the operating model agent digests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 19:49:28 +01:00

1.4 KiB

Service accounts and IAM grants

One service account per workload identity, and one _iam_member resource per grant.

  • account_id is 6 to 30 characters: lower-case letters, digits and hyphens.
  • Use the narrowest resource the role can be granted on: the bucket, topic, secret or service, in preference to the project.
  • A grant to a service account is member = "serviceAccount:${...email}". The same value is the member attribute of the service account resource.
variable "project_id" {
  type        = string
  description = "Project to deploy into."
}

variable "region" {
  type        = string
  description = "Region for regional resources."
}

resource "google_service_account" "worker" {
  project      = var.project_id
  account_id   = "event-worker"
  display_name = "Event worker"
  description  = "Identity of the worker service."
}

# A project-level role, only when no narrower resource can take the grant.
resource "google_project_iam_member" "worker_metrics" {
  project = var.project_id
  role    = "roles/monitoring.metricWriter"
  member  = google_service_account.worker.member
}

# Who may act as the service account, for example a deployment pipeline.
resource "google_service_account_iam_member" "deployer_acts_as_worker" {
  service_account_id = google_service_account.worker.name
  role               = "roles/iam.serviceAccountUser"
  member             = "serviceAccount:deployer@${var.project_id}.iam.gserviceaccount.com"
}