Route 53 public DNS query logging is not configured

Record DNS queries for public hosted zones that need detailed logs.

Description

Public hosted zone query logs record DNS requests that reach Route 53 and the response codes it returns. Queries answered from a resolver’s cache never reach the zone.

Potential impact

Without individual records, DNS errors and unusual queries are harder to trace to a particular name.

Remediation

Create a log group in us-east-1 in the hosted zone’s AWS account. Allow Route 53 to write through a Logs resource policy. Connect the zone and group with aws_route53_query_log and verify that new records arrive. Use Resolver query logging for private DNS.

Examples

The examples also rename the Terraform zone resource. Keep its existing address or declare the rename with a moved block to avoid replacing the zone.

Before

hcl
resource "aws_route53_zone" "example" {
  name = "example.com"
}

After

hcl
resource "aws_route53_zone" "example_com" {
  name = "example.com"
}

resource "aws_route53_query_log" "example_com" {
  depends_on = [aws_cloudwatch_log_resource_policy.route53-query-logging-policy]

  cloudwatch_log_group_arn = aws_cloudwatch_log_group.aws_route53_example_com.arn
  zone_id                  = aws_route53_zone.example_com.zone_id
}

References