generated from rhythmictech/terraform-terraform-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhealth.tf
135 lines (120 loc) · 3.33 KB
/
health.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
resource "aws_cloudwatch_event_rule" "awshealth" {
count = var.enable_health_notifications ? 1 : 0
name_prefix = substr("awshealth-event-${var.name}", 0, 35)
description = "Match on AWS Health alert (Datadog)"
event_pattern = <<EOT
{
"detail-type": [
"AWS Health Event"
],
"source": [
"aws.health"
]
}
EOT
}
resource "aws_cloudwatch_event_target" "awshealth" {
count = var.enable_health_notifications ? 1 : 0
arn = try(aws_cloudformation_stack.datadog_forwarder[0].outputs.DatadogForwarderArn, "")
rule = aws_cloudwatch_event_rule.awshealth[0].name
target_id = "send-to-datadog"
}
resource "aws_lambda_permission" "awshealth_trigger" {
count = var.enable_health_notifications ? 1 : 0
action = "lambda:InvokeFunction"
function_name = try(aws_cloudformation_stack.datadog_forwarder[0].outputs.DatadogForwarderArn, "")
principal = "events.amazonaws.com"
source_arn = aws_cloudwatch_event_rule.awshealth[0].arn
statement_id = "AWSHealthTrigger"
}
resource "datadog_logs_custom_pipeline" "health" {
count = var.enable_health_notifications ? 1 : 0
filter {
query = "source:health"
}
name = "AWS Health"
is_enabled = true
processor {
service_remapper {
is_enabled = true
name = "Map `detail.service` to attribute `service`"
sources = [
"detail.service"
]
}
}
processor {
message_remapper {
is_enabled = true
name = "Define `detail.eventDescription.0.latestDescription` as the message"
sources = [
"detail.eventDescription.0.latestDescription"
]
}
}
processor {
service_remapper {
is_enabled = true
name = "Map `detail.service` to service"
sources = [
"detail.service"
]
}
}
processor {
attribute_remapper {
is_enabled = true
name = "Map `detail.eventTypeCode` to event.name"
override_on_conflict = false
preserve_source = true
source_type = "attribute"
sources = [
"detail.eventTypeCode"
]
target = "evt.name"
target_type = "attribute"
}
}
processor {
attribute_remapper {
is_enabled = true
name = "Map `detail.statusCode` to attribute `outcome`"
override_on_conflict = false
preserve_source = true
source_type = "attribute"
sources = [
"detail.statusCode"
]
target = "evt.outcome"
target_type = "attribute"
}
}
processor {
attribute_remapper {
is_enabled = true
name = "Map `detail.affectedEntities.0.entityValue` to attribute `usr.id`"
override_on_conflict = false
preserve_source = true
source_type = "attribute"
sources = [
"detail.affectedEntities.0.entityValue"
]
target = "usr.id"
target_type = "attribute"
}
}
processor {
attribute_remapper {
is_enabled = true
name = "Map `detail.eventScopeCode` to tag `scope`"
override_on_conflict = false
preserve_source = true
source_type = "attribute"
sources = [
"detail.eventScopeCode",
]
target = "scope"
target_type = "tag"
}
}
}