Review GCP subnet VPC Flow Logs collection

Verify that the required network flow records are actually collected.

Description

A subnet can already have VPC Flow Logs coverage without log_config. Check for Network Management API configurations on the subnet, VPC or organization.

Potential impact

Flow logs contain sampled, aggregated traffic records. Gaps in coverage make it harder to investigate unexpected connections or verify a firewall change.

Remediation

To collect at the subnet with log_config, choose the aggregation interval, sampling rate and metadata for your investigation needs and budget. After traffic passes, look for records from this subnet in Cloud Logging and check read access and retention.

Examples

Supply the actual project and VPC. The second example aggregates over ten minutes, keeps 50% of the resulting flow records during secondary sampling and includes all metadata.

Before

hcl
resource "google_compute_subnetwork" "subnet" {
  name          = "log-test-subnetwork"
  ip_cidr_range = "10.2.0.0/16"
  region        = "us-central1"
  network       = google_compute_network.custom.id
}

After

hcl
resource "google_compute_subnetwork" "subnet" {
  name          = "log-test-subnetwork"
  ip_cidr_range = "10.2.0.0/16"
  region        = "us-central1"
  network       = google_compute_network.custom.id

  log_config {
    aggregation_interval = "INTERVAL_10_MIN"
    flow_sampling        = 0.5
    metadata             = "INCLUDE_ALL_METADATA"
  }
}

References