Terraform
2min
Our Terraform provider is available at:
main.tf
1terraform {
2 required_providers {
3 rootly = {
4 source = "rootlyhq/rootly"
5 }
6 }
7}
8
9# Configure the Rootly provider
10provider "rootly" {
11 # We recommend using the `ROOTLY_API_TOKEN` env var to set the API Token
12 # when interacting with Rootly's API.
13 # api_token = "<YOUR API KEY>"
14}
15
16# Severities
17resource "rootly_severity" "sev0" {
18 name = "SEV0"
19 color = "#FF0000"
20}
21
22resource "rootly_severity" "sev1" {
23 name = "SEV1"
24 color = "#FFA500"
25}
26
27resource "rootly_severity" "sev2" {
28 name = "SEV2"
29 color = "#FFA500"
30}
31
32# Services
33resource "rootly_service" "elasticsearch_prod" {
34 name = "elasticsearch-prod"
35 color = "#800080"
36}
37
38resource "rootly_service" "customer_postgresql_prod" {
39 name = "customer-postgresql-prod"
40 color = "#800080"
41}
42
43# Functionalities
44resource "rootly_functionality" "add_items_to_card" {
45 name = "Add items to cart"
46 color = "#800080"
47}
48
49resource "rootly_functionality" "logging_in" {
50 name = "Logging In"
51 color = "#800080"
52}
53
54# Custom Form Fields
55resource "rootly_form_field" "regions_affected" {
56 name = "Regions affected"
57 kind = "custom"
58 input_kind = "multi_select"
59 shown = ["web_new_incident_form", "web_update_incident_form"]
60 required = ["web_new_incident_form", "web_update_incident_form"]
61}
62
63resource "rootly_form_field_option" "asia" {
64 form_field_id = rootly_form_field.regions_affected.id
65 value = "Asia"
66}
67
68resource "rootly_form_field_option" "europe" {
69 form_field_id = rootly_form_field.regions_affected.id
70 value = "Europe"
71}
72
73resource "rootly_form_field_option" "north_america" {
74 form_field_id = rootly_form_field.regions_affected.id
75 value = "North America"
76}
77
78# Jira workflow
79resource "rootly_workflow_incident" "jira" {
80 name = "Create a Jira Issue"
81 description = "Open Jira ticket whenever incident starts"
82 trigger_params {
83 triggers = ["incident_created"]
84 incident_condition_kind = "IS"
85 incident_kinds = ["normal"]
86 incident_condition_status = "IS"
87 incident_statuses = ["started"]
88 }
89 enabled = true
90}
91
92resource "rootly_workflow_task_create_jira_issue" "jira" {
93 workflow_id = rootly_workflow_incident.jira.id
94 task_params {
95 title = "{{ incident.title }}"
96 description = "{{ incident.summary }}"
97 project_key = "ROOT"
98 issue_type = {
99 id = "10001"
100 name = "Task"
101 }
102 status = {
103 id = "10000"
104 name = "To Do"
105 }
106 labels = "{{ incident.environment_slugs | concat: incident.service_slugs | concat: incident.functionality_slugs | concat: incident.group_slugs | join: \",\" }}"
107 }
108}