QueryLog
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 Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var us_east_1 = new Aws.Provider("us-east-1", new Aws.ProviderArgs
{
Region = "us-east-1",
});
var awsRoute53ExampleCom = new Aws.CloudWatch.LogGroup("awsRoute53ExampleCom", new Aws.CloudWatch.LogGroupArgs
{
RetentionInDays = 30,
}, new CustomResourceOptions
{
Provider = "aws.us-east-1",
});
var route53_query_logging_policyPolicyDocument = Output.Create(Aws.Iam.GetPolicyDocument.InvokeAsync(new Aws.Iam.GetPolicyDocumentArgs
{
Statements =
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementArgs
{
Actions =
{
"logs:CreateLogStream",
"logs:PutLogEvents",
},
Principals =
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalArgs
{
Identifiers =
{
"route53.amazonaws.com",
},
Type = "Service",
},
},
Resources =
{
"arn:aws:logs:*:*:log-group:/aws/route53/*",
},
},
},
}));
var route53_query_logging_policyLogResourcePolicy = new Aws.CloudWatch.LogResourcePolicy("route53-query-logging-policyLogResourcePolicy", new Aws.CloudWatch.LogResourcePolicyArgs
{
PolicyDocument = route53_query_logging_policyPolicyDocument.Apply(route53_query_logging_policyPolicyDocument => route53_query_logging_policyPolicyDocument.Json),
PolicyName = "route53-query-logging-policy",
}, new CustomResourceOptions
{
Provider = "aws.us-east-1",
});
var exampleComZone = new Aws.Route53.Zone("exampleComZone", new Aws.Route53.ZoneArgs
{
});
var exampleComQueryLog = new Aws.Route53.QueryLog("exampleComQueryLog", new Aws.Route53.QueryLogArgs
{
CloudwatchLogGroupArn = awsRoute53ExampleCom.Arn,
ZoneId = exampleComZone.ZoneId,
}, new CustomResourceOptions
{
DependsOn =
{
"aws_cloudwatch_log_resource_policy.route53-query-logging-policy",
},
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/cloudwatch"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/providers"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/route53"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := providers.Newaws(ctx, "us_east_1", &providers.awsArgs{
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.us-east-1"))
if err != nil {
return err
}
route53_query_logging_policyPolicyDocument, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
Statements: []iam.GetPolicyDocumentStatement{
iam.GetPolicyDocumentStatement{
Actions: []string{
"logs:CreateLogStream",
"logs:PutLogEvents",
},
Principals: []iam.GetPolicyDocumentStatementPrincipal{
iam.GetPolicyDocumentStatementPrincipal{
Identifiers: []string{
"route53.amazonaws.com",
},
Type: "Service",
},
},
Resources: []string{
"arn:aws:logs:*:*:log-group:/aws/route53/*",
},
},
},
}, 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.us-east-1"))
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{
"aws_cloudwatch_log_resource_policy.route53-query-logging-policy",
}))
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
import pulumi_pulumi as pulumi
us_east_1 = pulumi.providers.Aws("us-east-1", region="us-east-1")
aws_route53_example_com = aws.cloudwatch.LogGroup("awsRoute53ExampleCom", retention_in_days=30,
opts=ResourceOptions(provider="aws.us-east-1"))
route53_query_logging_policy_policy_document = aws.iam.get_policy_document(statements=[{
"actions": [
"logs:CreateLogStream",
"logs:PutLogEvents",
],
"principals": [{
"identifiers": ["route53.amazonaws.com"],
"type": "Service",
}],
"resources": ["arn:aws:logs:*:*:log-group:/aws/route53/*"],
}])
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=ResourceOptions(provider="aws.us-east-1"))
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=ResourceOptions(depends_on=["aws_cloudwatch_log_resource_policy.route53-query-logging-policy"]))import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const us_east_1 = new aws.Provider("us-east-1", {
region: "us-east-1",
});
const exampleComZone = new aws.route53.Zone("example_com", {});
const awsRoute53ExampleCom = new aws.cloudwatch.LogGroup("aws_route53_example_com", {
retentionInDays: 30,
}, { provider: us_east_1 });
const route53_query_logging_policyPolicyDocument = pulumi.output(aws.iam.getPolicyDocument({
statements: [{
actions: [
"logs:CreateLogStream",
"logs:PutLogEvents",
],
principals: [{
identifiers: ["route53.amazonaws.com"],
type: "Service",
}],
resources: ["arn:aws:logs:*:*:log-group:/aws/route53/*"],
}],
}, { async: true }));
const route53_query_logging_policyLogResourcePolicy = new aws.cloudwatch.LogResourcePolicy("route53-query-logging-policy", {
policyDocument: route53_query_logging_policyPolicyDocument.json,
policyName: "route53-query-logging-policy",
}, { provider: us_east_1 });
const exampleComQueryLog = new aws.route53.QueryLog("example_com", {
cloudwatchLogGroupArn: awsRoute53ExampleCom.arn,
zoneId: exampleComZone.zoneId,
}, { dependsOn: [route53_query_logging_policyLogResourcePolicy] });Create a QueryLog Resource
new QueryLog(name: string, args: QueryLogArgs, opts?: CustomResourceOptions);def QueryLog(resource_name, opts=None, cloudwatch_log_group_arn=None, zone_id=None, __props__=None);func NewQueryLog(ctx *Context, name string, args QueryLogArgs, opts ...ResourceOption) (*QueryLog, error)public QueryLog(string name, QueryLogArgs args, CustomResourceOptions? opts = null)- 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.
- opts ResourceOptions
- A bag of options that control this 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.
QueryLog Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
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_ strgroup_ arn CloudWatch log group ARN to send query logs.
- zone_
id str 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 an 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): QueryLogstatic get(resource_name, id, opts=None, cloudwatch_log_group_arn=None, zone_id=None, __props__=None);func 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)- 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.
The following state arguments are supported:
- 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.
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.