Enable Subnetwork Private Google Access

LOW
Source
Trivy
ID
AVD-GCP-0075

Google Compute Subnetwork with Private Google Access Disabled

Private Google Access allows instances in a subnet to reach Google APIs and services via internal IP, which should be enabled for private networks.

Impact

Follow the appropriate remediation steps below to resolve the issue.

Enable Private Google Access on subnets. In Terraform, set private_ip_google_access = true in the google_compute_subnetwork resource.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
resource "google_compute_subnetwork" "good_example" {
  name                     = "test-subnetwork"
  ip_cidr_range            = "10.2.0.0/16"
  region                   = "us-central1"
  network                  = google_compute_network.custom-test.id
  private_ip_google_access = true
}
resource "google_compute_network" "custom-test" {
  name                    = "test-network"
  auto_create_subnetworks = false
}