Skip to content

Commit

Permalink
Adding CW dns query logs
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenvaines-bjss committed Jul 17, 2024
1 parent 119780d commit 4261408
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion infrastructure/terraform/components/acct/.tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
terraform 1.8.5
terraform 1.9.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
resource "aws_cloudwatch_log_group" "aws_route53_query_log" {
provider = aws.us-east-1 # Route53 query logging must be in us-east-1 https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_query_log

name = "/aws/route53/${local.csi}"
retention_in_days = var.log_retention_in_days
}

resource "aws_cloudwatch_log_resource_policy" "route53_query_logging_policy" {
provider = aws.us-east-1 # Route53 query logging must be in us-east-1 https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_query_log

policy_document = data.aws_iam_policy_document.route53_logs.json
policy_name = "${local.csi}-route53-query-logging-policy"
}

data "aws_iam_policy_document" "route53_logs" {
statement {
effect = "Allow"

principals {
type = "Service"

identifiers = [
"route53.amazonaws.com"
]
}

actions = [
"logs:CreateLogStream",
"logs:PutLogEvents",
]

resources = [
aws_cloudwatch_log_group.aws_route53_query_log.arn,
"${aws_cloudwatch_log_group.aws_route53_query_log.arn}:*"
]
}
}
9 changes: 9 additions & 0 deletions infrastructure/terraform/components/acct/route53_query_log.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resource "aws_route53_query_log" "main" {
zone_id = aws_route53_zone.main.zone_id

cloudwatch_log_group_arn = aws_cloudwatch_log_group.aws_route53_query_log.arn

depends_on = [
aws_cloudwatch_log_resource_policy.route53_query_logging_policy
]
}
2 changes: 1 addition & 1 deletion infrastructure/terraform/components/branch/.tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
terraform 1.8.5
terraform 1.9.2
2 changes: 1 addition & 1 deletion infrastructure/terraform/components/iam/.tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
terraform 1.8.5
terraform 1.9.2

0 comments on commit 4261408

Please sign in to comment.