/** * Google Cloud Organization Security Guardrails * Maintained by Sachan & Partners (https://sachanpartners.co.uk) */ variable "project_id" { type = string description = "The target Google Cloud Project ID" } # 1. Prevent creation of static, long-lived service account JSON keys resource "google_org_policy_policy" "disable_sa_keys" { name = "projects/${var.project_id}/policies/iam.disableServiceAccountKeyCreation" parent = "projects/${var.project_id}" spec { rules { enforce = "TRUE" } } } # 2. Enforce Public Access Prevention across all Google Cloud Storage Buckets resource "google_org_policy_policy" "no_public_buckets" { name = "projects/${var.project_id}/policies/storage.publicAccessPrevention" parent = "projects/${var.project_id}" spec { rules { enforce = "TRUE" } } } # 3. Restrict external IP addresses on Compute Engine instances resource "google_org_policy_policy" "restrict_public_ips" { name = "projects/${var.project_id}/policies/compute.vmExternalIpAccess" parent = "projects/${var.project_id}" spec { rules { deny_all = "TRUE" } } }