# 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. ```hcl 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"] } } ```