-
Notifications
You must be signed in to change notification settings - Fork 1
/
logs.tf
70 lines (62 loc) · 2.6 KB
/
logs.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
resource "aws_cloudwatch_log_group" "this" {
count = var.is_create_logging_configuration ? 1 : 0
name = format("aws-waf-logs-%s", var.name)
retention_in_days = var.cloudwatch_log_retention_in_days
kms_key_id = var.cloudwatch_log_kms_key_id
tags = merge(
local.tags,
{ "Name" = format("aws-waf-logs-%s", var.name) }
)
}
resource "aws_wafv2_web_acl_logging_configuration" "main" {
count = var.is_create_logging_configuration ? 1 : 0
log_destination_configs = [aws_cloudwatch_log_group.this[0].arn]
resource_arn = aws_wafv2_web_acl.this.arn
dynamic "redacted_fields" {
for_each = var.redacted_fields
content {
dynamic "single_header" {
for_each = length(lookup(redacted_fields.value, "single_header", {})) == 0 ? [] : [lookup(redacted_fields.value, "single_header", {})]
content {
name = lookup(single_header.value, "name", null)
}
}
dynamic "single_query_argument" {
for_each = length(lookup(redacted_fields.value, "single_query_argument", {})) == 0 ? [] : [lookup(redacted_fields.value, "single_query_argument", {})]
content {
name = lookup(single_query_argument.value, "name", null)
}
}
}
}
dynamic "logging_filter" {
for_each = length(var.logging_filter) == 0 ? [] : [var.logging_filter]
content {
default_behavior = lookup(logging_filter.value, "default_behavior", "KEEP")
dynamic "filter" {
for_each = length(lookup(logging_filter.value, "filter", {})) == 0 ? [] : toset(lookup(logging_filter.value, "filter"))
content {
behavior = lookup(filter.value, "behavior")
requirement = lookup(filter.value, "requirement", "MEETS_ANY")
dynamic "condition" {
for_each = length(lookup(filter.value, "condition", {})) == 0 ? [] : toset(lookup(filter.value, "condition"))
content {
dynamic "action_condition" {
for_each = length(lookup(condition.value, "action_condition", {})) == 0 ? [] : [lookup(condition.value, "action_condition", {})]
content {
action = lookup(action_condition.value, "action")
}
}
dynamic "label_name_condition" {
for_each = length(lookup(condition.value, "label_name_condition", {})) == 0 ? [] : [lookup(condition.value, "label_name_condition", {})]
content {
label_name = lookup(label_name_condition.value, "label_name")
}
}
}
}
}
}
}
}
}