For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/terraform-gcp-google-compute-subnetwork-with-private-google-access-disabled.md.
A documentation index is available at /llms.txt.
Enabling Private Google Access for a Google Compute Subnetwork by setting the private_ip_google_access attribute to true allows resources with only internal IP addresses to access Google APIs and services securely, without requiring external IP addresses. If this setting is not enabled, resources within the subnetwork are unable to directly reach Google services without public internet routes, increasing the risk of misconfigurations that may expose internal resources or disrupt service communications. To address this, ensure the configuration includes private_ip_google_access = true:
resource "google_compute_subnetwork" "example" {
name = "secure-subnetwork"
ip_cidr_range = "10.2.0.0/16"
region = "us-central1"
network = google_compute_network.custom-test.id
private_ip_google_access = true
}