-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotification_policy.tf
More file actions
274 lines (235 loc) · 6.07 KB
/
notification_policy.tf
File metadata and controls
274 lines (235 loc) · 6.07 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# WARNING: プランによっては使えない通知もあるため,追加する前に要確認
# 利用可能な通知は公式ドキュメントを確認
# https://developers.cloudflare.com/notifications/notification-available/
locals {
pages_project_ids = [
data.cloudflare_pages_project.train_photo_blog.canonical_deployment.project_id,
]
}
#
# Default
#
resource "cloudflare_notification_policy" "real_origin_monitoring_to_email" {
account_id = var.cloudflare_account_id
enabled = true
alert_type = "real_origin_monitoring"
name = "Passive Origin Monitoring"
description = "Recieve an email when your origin becomes unreachable"
filters = {}
mechanisms = {
email = [
{
id = var.admin_gmail_address
}
]
}
}
#
# Cloudflare Status
#
resource "cloudflare_notification_policy" "maintenance_event_notification" {
account_id = var.cloudflare_account_id
enabled = false
alert_type = "maintenance_event_notification"
name = "Maintenance event notification"
description = "Maintenance event"
filters = {}
mechanisms = {
webhooks = [
{
id = cloudflare_notification_policy_webhooks.slack_status.id
}
]
}
}
resource "cloudflare_notification_policy" "incident_alert" {
account_id = var.cloudflare_account_id
enabled = false
alert_type = "incident_alert"
name = "Incident alert"
description = "Incident alert"
filters = {}
mechanisms = {
webhooks = [
{
id = cloudflare_notification_policy_webhooks.slack_status.id
}
]
}
}
#
# Pages
#
resource "cloudflare_notification_policy" "pages_event_alert_prod" {
account_id = var.cloudflare_account_id
enabled = true
alert_type = "pages_event_alert"
name = "Pages Prod event alert"
description = "Cloudflare Pages Production event alert"
mechanisms = {
webhooks = [
{
id = cloudflare_notification_policy_webhooks.slack_pages_prod.id
}
]
}
filters = {
# 本番環境のデプロイのみ受け取る
environment = ["ENVIRONMENT_PRODUCTION"]
event = ["EVENT_DEPLOYMENT_STARTED", "EVENT_DEPLOYMENT_FAILED", "EVENT_DEPLOYMENT_SUCCESS"]
project_id = local.pages_project_ids
}
}
resource "cloudflare_notification_policy" "pages_event_alert_preview" {
account_id = var.cloudflare_account_id
enabled = true
alert_type = "pages_event_alert"
name = "Pages Preview event alert"
description = "Cloudflare Pages Preview event alert"
mechanisms = {
webhooks = [
{
id = cloudflare_notification_policy_webhooks.slack_pages_preview.id
}
]
}
filters = {
# プレビュー環境のデプロイのみ受け取る
environment = ["ENVIRONMENT_PREVIEW"]
event = ["EVENT_DEPLOYMENT_STARTED", "EVENT_DEPLOYMENT_FAILED", "EVENT_DEPLOYMENT_SUCCESS"]
project_id = local.pages_project_ids
}
}
#
# SSL/TLS
#
resource "cloudflare_notification_policy" "universal_ssl_event_type" {
account_id = var.cloudflare_account_id
enabled = true
alert_type = "universal_ssl_event_type"
name = "Universal ssl event type"
description = "Universal ssl event"
filters = {}
mechanisms = {
webhooks = [
{
id = cloudflare_notification_policy_webhooks.slack.id
}
]
}
}
#
# Tunnel
#
resource "cloudflare_notification_policy" "tunnel_health_event" {
account_id = var.cloudflare_account_id
enabled = true
alert_type = "tunnel_health_event"
name = "Tunnel health event"
description = "Cloudflare Tunnel health event"
filters = {}
mechanisms = {
webhooks = [
{
id = cloudflare_notification_policy_webhooks.slack_tunnel.id
}
]
}
}
resource "cloudflare_notification_policy" "tunnel_update_event" {
account_id = var.cloudflare_account_id
enabled = true
alert_type = "tunnel_update_event"
name = "Tunnel update event"
description = "Cloudflare Tunnel update event"
filters = {}
mechanisms = {
webhooks = [
{
id = cloudflare_notification_policy_webhooks.slack_tunnel.id
}
]
}
}
#
# Web Analytics
#
resource "cloudflare_notification_policy" "web_analytics_metrics_update" {
account_id = var.cloudflare_account_id
enabled = true
alert_type = "web_analytics_metrics_update"
name = "Web analytics metrics update"
description = "Web analytics metrics update"
filters = {}
mechanisms = {
webhooks = [
{
id = cloudflare_notification_policy_webhooks.slack.id
}
]
}
}
#
# DDoS Protection
#
resource "cloudflare_notification_policy" "dos_attack_l7" {
account_id = var.cloudflare_account_id
enabled = true
alert_type = "dos_attack_l7"
name = "HTTP DDoS Attack Alert"
description = "HTTP DDoS Attack Alert"
filters = {}
mechanisms = {
webhooks = [
{
id = cloudflare_notification_policy_webhooks.slack.id
}
]
}
}
#
# Security Center
#
resource "cloudflare_notification_policy" "security_insights_alert" {
account_id = var.cloudflare_account_id
enabled = true
alert_type = "security_insights_alert"
name = "Security Insights"
description = "Security Insights"
filters = {
insight_class = [
"always_https_not_enabled",
"no_challenge_ai_bots",
"no_block_ai_bots",
"response_size_anomaly_on_endpoint",
"increased_error_rate_on_endpoint",
"increased_latency_on_endpoint",
"sensitive_data_on_endpoint",
"update_bots_model",
"manage_bot_fight_mode",
"casb_unhealthy_integrations",
]
}
mechanisms = {
webhooks = [
{
id = cloudflare_notification_policy_webhooks.slack.id
}
]
}
}
resource "cloudflare_notification_policy" "abuse_report_alert" {
account_id = var.cloudflare_account_id
enabled = true
alert_type = "abuse_report_alert"
name = "Abuse report"
description = "Abuse report"
filters = {}
mechanisms = {
webhooks = [
{
id = cloudflare_notification_policy_webhooks.slack.id
}
]
}
}