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>
2.1 KiB
2.1 KiB
Cloud Storage bucket
One bucket with its retention, lifecycle rules, encryption and grants. Use the module when the bucket has several of those; a plain bucket is one resource and is written directly.
- The module turns on uniform bucket-level access (
bucket_policy_only) andpublic_access_prevention = "enforced"unless told otherwise. retention_policy.retention_periodis in seconds.is_locked = truecannot be undone, and the bucket cannot then be deleted until every object has aged out: take it from a variable.lifecycle_rulestakesactionandconditionas maps; condition values that are lists are given as comma-separated strings.encryption.default_kms_key_nameneeds the Cloud Storage service agent to hold the encrypter/decrypter role on the key first.iam_membersgrants on the bucket only, with_iam_member, so grants made elsewhere are kept.
variable "project_id" {
type = string
description = "Project to deploy into."
}
variable "region" {
type = string
description = "Region for regional resources."
}
variable "lock_retention" {
type = bool
description = "Whether the retention policy is locked. Locking cannot be undone."
default = false
}
variable "reader_service_account_email" {
type = string
description = "Service account that reads the archive."
}
module "archive" {
source = "terraform-google-modules/cloud-storage/google//modules/simple_bucket"
version = "12.4.1"
project_id = var.project_id
name = "${var.project_id}-archive"
location = var.region
storage_class = "STANDARD"
versioning = true
force_destroy = false
retention_policy = {
is_locked = var.lock_retention
retention_period = 220752000
}
lifecycle_rules = [
{
action = {
type = "SetStorageClass"
storage_class = "ARCHIVE"
}
condition = {
age = 365
}
}
]
iam_members = [
{
role = "roles/storage.objectViewer"
member = "serviceAccount:${var.reader_service_account_email}"
}
]
}