Ensure GCP subnet has a private IP Google access

Error: GCP subnet does not have a private IP Google access

Bridgecrew Policy ID: BC_GCP_GENERAL_31
Checkov Check ID: CKV_GCP_74
Severity: LOW

GCP subnet does not have a private IP Google access

Description

Enabling private IP Google access for your Google Cloud Platform (GCP) subnet can help improve the security and performance of your network. Private IP Google access allows resources in your subnet to access Google APIs and services over a private IP connection, rather than a public connection.

Fix - Runtime

Fix - Buildtime

Terraform

resource "google_compute_subnetwork" "pass" {
  name          = "example"
  ip_cidr_range = "10.0.0.0/16"
  network       = "google_compute_network.vpc.self_link"

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