Review GCP DNS policy query logging

Associate the DNS logging policy with its VPC and verify actual query records.

Description

Query logging on a Cloud DNS server policy records lookups sent to Cloud DNS from the associated VPC. Direct queries to a public zone have their own logging setting.

Potential impact

Without query logs, it can be hard to tell when a workload looked up a domain during an incident. A cached answer may not produce a new log entry for each request.

Remediation

Set enable_logging = true and associate the target VPC under networks. From that VPC, query an uncached name you control through Cloud DNS and find the query in Logs Explorer. Configure retention and reader access.

Examples

The excerpts omit the project and network association. They change only logging on the same policy. Both enable inbound forwarding, which is optional for query logging.

Before

hcl
resource "google_dns_policy" "policy" {
  name                      = "example-policy"
  enable_inbound_forwarding = true

  enable_logging = false
}

After

hcl
resource "google_dns_policy" "policy" {
  name                      = "example-policy"
  enable_inbound_forwarding = true

  enable_logging = true
}

References