feat: opt-in published Terraform modules from approved sources (iteration 8)
Infrastructure code is plain resources by default. An Execution may opt in with terraform_modules; the deployment default is TERRAFORM_MODULES, off. - A module is accepted only from the registry namespaces the provider bundle lists (terraform-google-modules), at one exact version. Any other source is refused before Terraform runs; until now nothing stopped generated code naming any source for terraform init to download. - terraform_module looks up a module's inputs, outputs and submodules from the registry and says when it cannot be used with the pinned provider. - skills/google-cloud-iac-modules: when a module fits, and four modules with examples a test validates against hashicorp/google 8.6.0. - Opted in, the IaC author and validator get the Skill and the lookup. Not opted in, they get neither and a module block is refused in code. - A Change request follows its Baseline. execution.json records the choice. - case-07 runs case 03's request with modules opted into. Azure (aztfm) and AWS (terraform-aws-modules) sources are recorded in the plan for when those Cloud providers are added. No case has run with this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
54
skills/google-cloud-iac-modules/references/kms.md
Normal file
54
skills/google-cloud-iac-modules/references/kms.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# 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"]
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user