# compliance-evaluation / gcp / t1 "Standard" # # Security Command Center findings for the whole organisation: every active # finding on one feed for the SIEM, high and critical ones on a second feed # for whoever is on call, accepted findings muted by named rules, and every # finding kept in BigQuery as a history. locals { active = "state = \"ACTIVE\" AND NOT mute = \"MUTED\"" urgent = join(" OR ", [for s in var.urgent_severities : "severity = \"${s}\""]) } resource "google_project_service" "needed" { for_each = toset(["securitycenter.googleapis.com", "pubsub.googleapis.com", "bigquery.googleapis.com"]) project = var.security_project service = each.value disable_on_destroy = false } resource "google_pubsub_topic" "feed" { for_each = toset(["all", "urgent"]) project = var.security_project name = "scc-findings-${each.value}" message_retention_duration = "604800s" depends_on = [google_project_service.needed] } resource "google_pubsub_subscription" "feed" { for_each = google_pubsub_topic.feed project = var.security_project name = each.value.name topic = each.value.id message_retention_duration = "604800s" expiration_policy { ttl = "" } } resource "google_scc_v2_organization_notification_config" "all" { organization = var.org_id location = "global" config_id = "all-active-findings" description = "Every active, unmuted finding in the organisation, for the SIEM." pubsub_topic = google_pubsub_topic.feed["all"].id streaming_config { filter = local.active } } resource "google_scc_v2_organization_notification_config" "urgent" { organization = var.org_id location = "global" config_id = "urgent-findings" description = "Active, unmuted findings of severity ${join(" or ", var.urgent_severities)}, for whoever is on call." pubsub_topic = google_pubsub_topic.feed["urgent"].id streaming_config { filter = "${local.active} AND (${local.urgent})" } } # Accepted findings leave both feeds and stay on record, so the reason can be # reviewed and the mute removed when the reason no longer applies. resource "google_scc_v2_organization_mute_config" "accepted" { for_each = var.mutes organization = var.org_id location = "global" mute_config_id = each.key description = "Accepted: ${each.key}" filter = each.value type = "STATIC" } resource "google_bigquery_dataset" "history" { project = var.security_project dataset_id = "scc_findings_history" location = var.bigquery_location description = "Every Security Command Center finding and its changes." default_table_expiration_ms = var.history_days * 86400000 depends_on = [google_project_service.needed] } resource "google_scc_v2_organization_scc_big_query_export" "history" { organization = var.org_id location = "global" big_query_export_id = "findings-history" description = "Every finding, for trends and audits." dataset = google_bigquery_dataset.history.id filter = "" }