published on Tuesday, Mar 10, 2026 by Pulumi
published on Tuesday, Mar 10, 2026 by Pulumi
Provides a Route53 query logging configuration resource.
NOTE: There are restrictions on the configuration of query logging. Notably, the CloudWatch log group must be in the
us-east-1region, a permissive CloudWatch log resource policy must be in place, and the Route53 hosted zone must be public. See Configuring Logging for DNS Queries for additional details.
Example Usage
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
// Example CloudWatch log group in us-east-1
var us_east_1 = new Aws.Provider("us-east-1", new()
{
Region = "us-east-1",
});
var awsRoute53ExampleCom = new Aws.CloudWatch.LogGroup("awsRoute53ExampleCom", new()
{
RetentionInDays = 30,
}, new CustomResourceOptions
{
Provider = aws.Us_east_1,
});
// Example CloudWatch log resource policy to allow Route53 to write logs
// to any log group under /aws/route53/*
var route53_query_logging_policyPolicyDocument = Aws.Iam.GetPolicyDocument.Invoke(new()
{
Statements = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
{
Actions = new[]
{
"logs:CreateLogStream",
"logs:PutLogEvents",
},
Resources = new[]
{
"arn:aws:logs:*:*:log-group:/aws/route53/*",
},
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Identifiers = new[]
{
"route53.amazonaws.com",
},
Type = "Service",
},
},
},
},
});
var route53_query_logging_policyLogResourcePolicy = new Aws.CloudWatch.LogResourcePolicy("route53-query-logging-policyLogResourcePolicy", new()
{
PolicyDocument = route53_query_logging_policyPolicyDocument.Apply(route53_query_logging_policyPolicyDocument => route53_query_logging_policyPolicyDocument.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json)),
PolicyName = "route53-query-logging-policy",
}, new CustomResourceOptions
{
Provider = aws.Us_east_1,
});
// Example Route53 zone with query logging
var exampleComZone = new Aws.Route53.Zone("exampleComZone");
var exampleComQueryLog = new Aws.Route53.QueryLog("exampleComQueryLog", new()
{
CloudwatchLogGroupArn = awsRoute53ExampleCom.Arn,
ZoneId = exampleComZone.ZoneId,
}, new CustomResourceOptions
{
DependsOn = new[]
{
route53_query_logging_policyLogResourcePolicy,
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/cloudwatch"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/route53"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := aws.NewProvider(ctx, "us-east-1", &aws.ProviderArgs{
Region: pulumi.String("us-east-1"),
})
if err != nil {
return err
}
awsRoute53ExampleCom, err := cloudwatch.NewLogGroup(ctx, "awsRoute53ExampleCom", &cloudwatch.LogGroupArgs{
RetentionInDays: pulumi.Int(30),
}, pulumi.Provider(aws.UsEast1))
if err != nil {
return err
}
route53_query_logging_policyPolicyDocument, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
Statements: []iam.GetPolicyDocumentStatement{
{
Actions: []string{
"logs:CreateLogStream",
"logs:PutLogEvents",
},
Resources: []string{
"arn:aws:logs:*:*:log-group:/aws/route53/*",
},
Principals: []iam.GetPolicyDocumentStatementPrincipal{
{
Identifiers: []string{
"route53.amazonaws.com",
},
Type: "Service",
},
},
},
},
}, nil)
if err != nil {
return err
}
_, err = cloudwatch.NewLogResourcePolicy(ctx, "route53-query-logging-policyLogResourcePolicy", &cloudwatch.LogResourcePolicyArgs{
PolicyDocument: *pulumi.String(route53_query_logging_policyPolicyDocument.Json),
PolicyName: pulumi.String("route53-query-logging-policy"),
}, pulumi.Provider(aws.UsEast1))
if err != nil {
return err
}
exampleComZone, err := route53.NewZone(ctx, "exampleComZone", nil)
if err != nil {
return err
}
_, err = route53.NewQueryLog(ctx, "exampleComQueryLog", &route53.QueryLogArgs{
CloudwatchLogGroupArn: awsRoute53ExampleCom.Arn,
ZoneId: exampleComZone.ZoneId,
}, pulumi.DependsOn([]pulumi.Resource{
route53_query_logging_policyLogResourcePolicy,
}))
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.Provider;
import com.pulumi.aws.ProviderArgs;
import com.pulumi.aws.cloudwatch.LogGroup;
import com.pulumi.aws.cloudwatch.LogGroupArgs;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.cloudwatch.LogResourcePolicy;
import com.pulumi.aws.cloudwatch.LogResourcePolicyArgs;
import com.pulumi.aws.route53.Zone;
import com.pulumi.aws.route53.QueryLog;
import com.pulumi.aws.route53.QueryLogArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var us_east_1 = new Provider("us-east-1", ProviderArgs.builder()
.region("us-east-1")
.build());
var awsRoute53ExampleCom = new LogGroup("awsRoute53ExampleCom", LogGroupArgs.builder()
.retentionInDays(30)
.build(), CustomResourceOptions.builder()
.provider(aws.us-east-1())
.build());
final var route53-query-logging-policyPolicyDocument = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.actions(
"logs:CreateLogStream",
"logs:PutLogEvents")
.resources("arn:aws:logs:*:*:log-group:/aws/route53/*")
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.identifiers("route53.amazonaws.com")
.type("Service")
.build())
.build())
.build());
var route53_query_logging_policyLogResourcePolicy = new LogResourcePolicy("route53-query-logging-policyLogResourcePolicy", LogResourcePolicyArgs.builder()
.policyDocument(route53_query_logging_policyPolicyDocument.json())
.policyName("route53-query-logging-policy")
.build(), CustomResourceOptions.builder()
.provider(aws.us-east-1())
.build());
var exampleComZone = new Zone("exampleComZone");
var exampleComQueryLog = new QueryLog("exampleComQueryLog", QueryLogArgs.builder()
.cloudwatchLogGroupArn(awsRoute53ExampleCom.arn())
.zoneId(exampleComZone.zoneId())
.build(), CustomResourceOptions.builder()
.dependsOn(route53_query_logging_policyLogResourcePolicy)
.build());
}
}
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
// Example CloudWatch log group in us-east-1
const us_east_1 = new aws.Provider("us-east-1", {region: "us-east-1"});
const awsRoute53ExampleCom = new aws.cloudwatch.LogGroup("awsRoute53ExampleCom", {retentionInDays: 30}, {
provider: aws["us-east-1"],
});
// Example CloudWatch log resource policy to allow Route53 to write logs
// to any log group under /aws/route53/*
const route53-query-logging-policyPolicyDocument = aws.iam.getPolicyDocument({
statements: [{
actions: [
"logs:CreateLogStream",
"logs:PutLogEvents",
],
resources: ["arn:aws:logs:*:*:log-group:/aws/route53/*"],
principals: [{
identifiers: ["route53.amazonaws.com"],
type: "Service",
}],
}],
});
const route53_query_logging_policyLogResourcePolicy = new aws.cloudwatch.LogResourcePolicy("route53-query-logging-policyLogResourcePolicy", {
policyDocument: route53_query_logging_policyPolicyDocument.then(route53_query_logging_policyPolicyDocument => route53_query_logging_policyPolicyDocument.json),
policyName: "route53-query-logging-policy",
}, {
provider: aws["us-east-1"],
});
// Example Route53 zone with query logging
const exampleComZone = new aws.route53.Zone("exampleComZone", {});
const exampleComQueryLog = new aws.route53.QueryLog("exampleComQueryLog", {
cloudwatchLogGroupArn: awsRoute53ExampleCom.arn,
zoneId: exampleComZone.zoneId,
}, {
dependsOn: [route53_query_logging_policyLogResourcePolicy],
});
import pulumi
import pulumi_aws as aws
# Example CloudWatch log group in us-east-1
us_east_1 = aws.Provider("us-east-1", region="us-east-1")
aws_route53_example_com = aws.cloudwatch.LogGroup("awsRoute53ExampleCom", retention_in_days=30,
opts=pulumi.ResourceOptions(provider=aws["us-east-1"]))
# Example CloudWatch log resource policy to allow Route53 to write logs
# to any log group under /aws/route53/*
route53_query_logging_policy_policy_document = aws.iam.get_policy_document(statements=[aws.iam.GetPolicyDocumentStatementArgs(
actions=[
"logs:CreateLogStream",
"logs:PutLogEvents",
],
resources=["arn:aws:logs:*:*:log-group:/aws/route53/*"],
principals=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(
identifiers=["route53.amazonaws.com"],
type="Service",
)],
)])
route53_query_logging_policy_log_resource_policy = aws.cloudwatch.LogResourcePolicy("route53-query-logging-policyLogResourcePolicy",
policy_document=route53_query_logging_policy_policy_document.json,
policy_name="route53-query-logging-policy",
opts=pulumi.ResourceOptions(provider=aws["us-east-1"]))
# Example Route53 zone with query logging
example_com_zone = aws.route53.Zone("exampleComZone")
example_com_query_log = aws.route53.QueryLog("exampleComQueryLog",
cloudwatch_log_group_arn=aws_route53_example_com.arn,
zone_id=example_com_zone.zone_id,
opts=pulumi.ResourceOptions(depends_on=[route53_query_logging_policy_log_resource_policy]))
resources:
# Example CloudWatch log group in us-east-1
us-east-1:
type: pulumi:providers:aws
properties:
region: us-east-1
awsRoute53ExampleCom: # Example CloudWatch log resource policy to allow Route53 to write logs
# to any log group under /aws/route53/*
type: aws:cloudwatch:LogGroup
properties:
retentionInDays: 30
options:
provider: ${aws"us-east-1"[%!s(MISSING)]}
route53-query-logging-policyLogResourcePolicy: # Example Route53 zone with query logging
type: aws:cloudwatch:LogResourcePolicy
properties:
policyDocument: ${["route53-query-logging-policyPolicyDocument"].json}
policyName: route53-query-logging-policy
options:
provider: ${aws"us-east-1"[%!s(MISSING)]}
exampleComZone:
type: aws:route53:Zone
exampleComQueryLog:
type: aws:route53:QueryLog
properties:
cloudwatchLogGroupArn: ${awsRoute53ExampleCom.arn}
zoneId: ${exampleComZone.zoneId}
options:
dependson:
- ${["route53-query-logging-policyLogResourcePolicy"]}
variables:
route53-query-logging-policyPolicyDocument:
fn::invoke:
Function: aws:iam:getPolicyDocument
Arguments:
statements:
- actions:
- logs:CreateLogStream
- logs:PutLogEvents
resources:
- arn:aws:logs:*:*:log-group:/aws/route53/*
principals:
- identifiers:
- route53.amazonaws.com
type: Service
Create QueryLog Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new QueryLog(name: string, args: QueryLogArgs, opts?: CustomResourceOptions);@overload
def QueryLog(resource_name: str,
args: QueryLogArgs,
opts: Optional[ResourceOptions] = None)
@overload
def QueryLog(resource_name: str,
opts: Optional[ResourceOptions] = None,
cloudwatch_log_group_arn: Optional[str] = None,
zone_id: Optional[str] = None)func NewQueryLog(ctx *Context, name string, args QueryLogArgs, opts ...ResourceOption) (*QueryLog, error)public QueryLog(string name, QueryLogArgs args, CustomResourceOptions? opts = null)
public QueryLog(String name, QueryLogArgs args)
public QueryLog(String name, QueryLogArgs args, CustomResourceOptions options)
type: aws:route53:QueryLog
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args QueryLogArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args QueryLogArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args QueryLogArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args QueryLogArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args QueryLogArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var queryLogResource = new Aws.Route53.QueryLog("queryLogResource", new()
{
CloudwatchLogGroupArn = "string",
ZoneId = "string",
});
example, err := route53.NewQueryLog(ctx, "queryLogResource", &route53.QueryLogArgs{
CloudwatchLogGroupArn: pulumi.String("string"),
ZoneId: pulumi.String("string"),
})
var queryLogResource = new QueryLog("queryLogResource", QueryLogArgs.builder()
.cloudwatchLogGroupArn("string")
.zoneId("string")
.build());
query_log_resource = aws.route53.QueryLog("queryLogResource",
cloudwatch_log_group_arn="string",
zone_id="string")
const queryLogResource = new aws.route53.QueryLog("queryLogResource", {
cloudwatchLogGroupArn: "string",
zoneId: "string",
});
type: aws:route53:QueryLog
properties:
cloudwatchLogGroupArn: string
zoneId: string
QueryLog Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The QueryLog resource accepts the following input properties:
- Cloudwatch
Log stringGroup Arn - CloudWatch log group ARN to send query logs.
- Zone
Id string - Route53 hosted zone ID to enable query logs.
- Cloudwatch
Log stringGroup Arn - CloudWatch log group ARN to send query logs.
- Zone
Id string - Route53 hosted zone ID to enable query logs.
- cloudwatch
Log StringGroup Arn - CloudWatch log group ARN to send query logs.
- zone
Id String - Route53 hosted zone ID to enable query logs.
- cloudwatch
Log stringGroup Arn - CloudWatch log group ARN to send query logs.
- zone
Id string - Route53 hosted zone ID to enable query logs.
- cloudwatch_
log_ strgroup_ arn - CloudWatch log group ARN to send query logs.
- zone_
id str - Route53 hosted zone ID to enable query logs.
- cloudwatch
Log StringGroup Arn - CloudWatch log group ARN to send query logs.
- zone
Id String - Route53 hosted zone ID to enable query logs.
Outputs
All input properties are implicitly available as output properties. Additionally, the QueryLog resource produces the following output properties:
Look up Existing QueryLog Resource
Get an existing QueryLog resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: QueryLogState, opts?: CustomResourceOptions): QueryLog@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
arn: Optional[str] = None,
cloudwatch_log_group_arn: Optional[str] = None,
zone_id: Optional[str] = None) -> QueryLogfunc GetQueryLog(ctx *Context, name string, id IDInput, state *QueryLogState, opts ...ResourceOption) (*QueryLog, error)public static QueryLog Get(string name, Input<string> id, QueryLogState? state, CustomResourceOptions? opts = null)public static QueryLog get(String name, Output<String> id, QueryLogState state, CustomResourceOptions options)resources: _: type: aws:route53:QueryLog get: id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Arn string
- The Amazon Resource Name (ARN) of the Query Logging Config.
- Cloudwatch
Log stringGroup Arn - CloudWatch log group ARN to send query logs.
- Zone
Id string - Route53 hosted zone ID to enable query logs.
- Arn string
- The Amazon Resource Name (ARN) of the Query Logging Config.
- Cloudwatch
Log stringGroup Arn - CloudWatch log group ARN to send query logs.
- Zone
Id string - Route53 hosted zone ID to enable query logs.
- arn String
- The Amazon Resource Name (ARN) of the Query Logging Config.
- cloudwatch
Log StringGroup Arn - CloudWatch log group ARN to send query logs.
- zone
Id String - Route53 hosted zone ID to enable query logs.
- arn string
- The Amazon Resource Name (ARN) of the Query Logging Config.
- cloudwatch
Log stringGroup Arn - CloudWatch log group ARN to send query logs.
- zone
Id string - Route53 hosted zone ID to enable query logs.
- arn str
- The Amazon Resource Name (ARN) of the Query Logging Config.
- cloudwatch_
log_ strgroup_ arn - CloudWatch log group ARN to send query logs.
- zone_
id str - Route53 hosted zone ID to enable query logs.
- arn String
- The Amazon Resource Name (ARN) of the Query Logging Config.
- cloudwatch
Log StringGroup Arn - CloudWatch log group ARN to send query logs.
- zone
Id String - Route53 hosted zone ID to enable query logs.
Import
Route53 query logging configurations can be imported using their ID, e.g.,
$ pulumi import aws:route53/queryLog:QueryLog example_com xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.
published on Tuesday, Mar 10, 2026 by Pulumi
