Files
solution_architecture_agent/skills/google-cloud-iac-modules/references/kms.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.8 KiB

Cloud KMS key ring and keys

A key ring, its keys and the grants that let products use them. Replaces a key ring, each key and each grant.

  • The key ring's location must match the resource it protects.
  • prevent_destroy is true unless set otherwise; keys and key rings cannot be deleted from Google Cloud in any case.
  • key_rotation_period is in seconds with an s, such as "7776000s" for 90 days.
  • set_encrypters_for and set_decrypters_for name the keys; encrypters and decrypters give one comma-separated string of members per key, in the same order.
  • The member is the product's service agent, not the workload's service account.
  • module.kms.keys is a map from key name to key id.
variable "project_id" {
  type        = string
  description = "Project to deploy into."
}

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

data "google_storage_project_service_account" "this" {
  project = var.project_id
}

module "kms" {
  source  = "terraform-google-modules/kms/google"
  version = "4.2.1"

  project_id          = var.project_id
  location            = var.region
  keyring             = "workload"
  keys                = ["data"]
  key_rotation_period = "7776000s"
  prevent_destroy     = true

  set_encrypters_for = ["data"]
  set_decrypters_for = ["data"]
  encrypters         = ["serviceAccount:${data.google_storage_project_service_account.this.email_address}"]
  decrypters         = ["serviceAccount:${data.google_storage_project_service_account.this.email_address}"]
}

resource "google_storage_bucket" "encrypted" {
  project                     = var.project_id
  name                        = "${var.project_id}-encrypted"
  location                    = var.region
  uniform_bucket_level_access = true

  encryption {
    default_kms_key_name = module.kms.keys["data"]
  }
}