-
Notifications
You must be signed in to change notification settings - Fork 12
/
services.tf
100 lines (92 loc) · 3.25 KB
/
services.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
/*
PagerDuty Services, Integrations, Dependencies, and Maintenance Windows
- https://www.terraform.io/docs/providers/pagerduty/r/business_service.html
- https://www.terraform.io/docs/providers/pagerduty/r/service.html
- https://www.terraform.io/docs/providers/pagerduty/r/service_dependency.html
- https://www.terraform.io/docs/providers/pagerduty/r/service_integration.html
- https://www.terraform.io/docs/providers/pagerduty/r/maintenance_window.html
*/
/*
Business Service (e.g. higher-level business application)
*/
resource "pagerduty_business_service" "example_application" {
name = "Example Application"
description = "Example application represented by a business service"
point_of_contact = "Operations"
}
/*
Technical Services (e.g. lower-level microservices)
*/
resource "pagerduty_service" "example_application_website" {
name = "Website"
auto_resolve_timeout = 14400
acknowledgement_timeout = 600
escalation_policy = pagerduty_escalation_policy.support.id
alert_creation = "create_alerts_and_incidents"
incident_urgency_rule {
type = "constant"
urgency = "severity_based"
}
}
resource "pagerduty_service" "example_application_database" {
name = "Database"
auto_resolve_timeout = 14400
acknowledgement_timeout = 600
escalation_policy = pagerduty_escalation_policy.operations.id
alert_creation = "create_alerts_and_incidents"
incident_urgency_rule {
type = "constant"
urgency = "severity_based"
}
}
/*
Service Dependencies
*/
resource "pagerduty_service_dependency" "example_application_website" {
dependency {
dependent_service {
id = pagerduty_business_service.example_application.id
type = "business_service"
}
supporting_service {
id = pagerduty_service.example_application_website.id
type = "service"
}
}
}
resource "pagerduty_service_dependency" "example_application_database" {
dependency {
dependent_service {
id = pagerduty_business_service.example_application.id
type = "business_service"
}
supporting_service {
id = pagerduty_service.example_application_database.id
type = "service"
}
}
}
/*
Technical Service Integrations (e.g. 3rd-party integration per technical service)
*/
resource "pagerduty_service_integration" "example_application_website_new_relic" {
name = "New Relic Integration"
vendor = data.pagerduty_vendor.new_relic.id
service = pagerduty_service.example_application_website.id
}
resource "pagerduty_service_integration" "example_application_database_splunk" {
name = "Splunk Integration"
vendor = data.pagerduty_vendor.splunk.id
service = pagerduty_service.example_application_database.id
}
/*
Technical Service Maintenance Window (e.g. disable creation of incidents during Christmas)
*/
resource "pagerduty_maintenance_window" "christmas_downtime" {
start_time = format("%s-12-24T17:00:00-00:00", formatdate("YYYY", timestamp()))
end_time = format("%s-12-26T09:00:00-00:00", formatdate("YYYY", timestamp()))
services = [
pagerduty_service.example_application_website.id,
pagerduty_service.example_application_database.id
]
}