Skip to content

Commit bffbe8c

Browse files
committed
Added Pagerduty Module
1 parent 6716fa8 commit bffbe8c

File tree

6 files changed

+172
-0
lines changed

6 files changed

+172
-0
lines changed

examples/pagerduty.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
provider "pagerduty" {
2+
token = "<PAGERDUTY_TOKEN>"
3+
}
4+
5+
### Pagerduty Module
6+
module "sumologic-jira-pagerduty-app" {
7+
source = "SumoLogic/integrations/sumologic//pagerduty"
8+
version = "{revision}"
9+
10+
sumo_access_id = "<SUMO_ACCESS_ID>"
11+
sumo_access_key = "<SUMO_ACCESS_KEY>"
12+
sumo_api_endpoint = "https://api.sumologic.com/api/v1/"
13+
collector_id = sumologic_collector.sumo_collector.id
14+
source_category = "Pagerduty"
15+
folder_id = sumologic_folder.folder.id
16+
pagerduty_services_pagerduty_webhooks = ["<PG_SERVICE1>","PG_SERVICE2"]
17+
app_version = "1.0"
18+
}

github/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
This module installs [Sumo Logic Github application](https://help.sumologic.com/07Sumo-Logic-Apps/08App_Development/Github) in Sumo Logic and configures Webhooks in Github to send events to Sumo Logic.
66

7+
Note: This module doesn't create the field required by Github App, please configure the field as defined [here](https://help.sumologic.com/07Sumo-Logic-Apps/08App_Development/GitHub/01Collect-Logs-for-the-GitHub-App#enable-github-event-tagging-at-sumo-logic).
8+
79
## Requirements
810

911
* [Terraform](https://www.terraform.io/downloads.html) >= 0.13.0

pagerduty/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Pagerduty
2+
3+
## Purpose
4+
5+
This module installs [Sumo Logic Pagerduty V2 application](https://help.sumologic.com/07Sumo-Logic-Apps/08App_Development/PagerDuty_V2) in Sumo Logic and configures Webhooks in Pagerduty to send events to Sumo Logic.
6+
7+
## Requirements
8+
9+
* [Terraform](https://www.terraform.io/downloads.html) >= 0.13.0
10+
* Null >= 2.1
11+
* Pagerduty >= 1.2
12+
13+
## Module Declaration
14+
15+
This module requires Sumo Logic collector Id and Folder id as explained [here](https://github.com/SumoLogic/terraform-sumologic-integrations#prerequisites-for-using-modules).
16+
17+
### Pagerduty Provider
18+
```shell
19+
provider "pagerduty" {
20+
token = "<PAGERDUTY_TOKEN>"
21+
}
22+
```
23+
24+
### Pagerduty Module
25+
```shell
26+
module "sumologic-jira-pagerduty-app" {
27+
source = "SumoLogic/integrations/sumologic//pagerduty"
28+
version = "{revision}"
29+
30+
sumo_access_id = "<SUMO_ACCESS_ID>"
31+
sumo_access_key = "<SUMO_ACCESS_KEY>"
32+
sumo_api_endpoint = "https://api.sumologic.com/api/v1/"
33+
collector_id = sumologic_collector.sumo_collector.id
34+
source_category = "Pagerduty"
35+
folder_id = sumologic_folder.folder.id
36+
pagerduty_services_pagerduty_webhooks = ["SERVICE_ID1","SERVICE_ID2"] # By default all events are configured.
37+
app_version = "1.0"
38+
}
39+
```
40+
41+
## Inputs
42+
43+
| Name | Description | Type | Default | Required |
44+
|------|-------------|------|---------|:-----:|
45+
|sumo_access_id|[Sumo Logic Access ID](https://help.sumologic.com/Manage/Security/Access-Keys)|string| |yes
46+
|sumo_access_key|[Sumo Logic Access Key](https://help.sumologic.com/Manage/Security/Access-Keys)|string| |yes
47+
|sumo_api_endpoint|[Sumo Logic API Endpoint](https://help.sumologic.com/APIs/General-API-Information/Sumo-Logic-Endpoints-and-Firewall-Security)|string|https://api.sumologic.com/api/v1/|yes
48+
|collector_id|Sumo Logic Collector ID|string| |yes
49+
|folder_id|Sumo Logic Folder ID|string| |yes
50+
|source_category|Pagerduty Source Category|string|Pagerduty|yes
51+
|pagerduty_services_pagerduty_webhooks|List of Pagerduty Service IDs. Example, ["P1QWK8J","PK9FKW3"]. You can get these from the URL after opening a specific service in Pagerduty. These are used for Pagerduty to Sumo Logic webhooks.|list| |yes
52+
|app_version|The app_version input parameter can be used to install a new copy of the app. When the app_version field is changed, it will force Terraform to install a new app folder with the current timestamp.|String|1.0|no

pagerduty/inputs.tf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Pagerduty
2+
variable "sumo_access_id" {
3+
type = string
4+
description = "Sumo Logic Access ID"
5+
}
6+
variable "sumo_access_key" {
7+
type = string
8+
description = "Sumo Logic Access Key"
9+
}
10+
variable "sumo_api_endpoint" {
11+
type = string
12+
description = "Sumo Logic Endpoint"
13+
default = "https://api.sumologic.com/api/v1/"
14+
}
15+
variable "collector_id" {
16+
type = string
17+
description = "Sumo Logic Collector ID"
18+
}
19+
variable "source_category" {
20+
type = string
21+
description = "Sumo Logic Pagerduty Source Category"
22+
default = "Pagerduty"
23+
}
24+
variable "folder_id" {
25+
type = string
26+
description = "Sumo Logic Content Folder ID"
27+
}
28+
variable "pagerduty_services_pagerduty_webhooks" {
29+
type = list
30+
description = "List of Pagerduty Service IDs"
31+
default = []
32+
}
33+
variable "app_version" {
34+
type = string
35+
description = "App Version"
36+
default = "1.0"
37+
}

pagerduty/main.tf

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Create/Delete Pagerduty Source
2+
resource "sumologic_http_source" "pagerduty" {
3+
name = "Pagerduty"
4+
category = var.source_category
5+
collector_id = var.collector_id
6+
}
7+
8+
data "pagerduty_extension_schema" "webhook" {
9+
name = "Generic V2 Webhook"
10+
}
11+
12+
# Create Webhook in Pagerduty
13+
resource "pagerduty_extension" "sumologic_extension" {
14+
count = length(var.pagerduty_services_pagerduty_webhooks) > 0 ? length(var.pagerduty_services_pagerduty_webhooks) : 0
15+
name = "Sumo Logic Webhook"
16+
endpoint_url = sumologic_http_source.pagerduty.url
17+
extension_schema = data.pagerduty_extension_schema.webhook.id
18+
extension_objects = [var.pagerduty_services_pagerduty_webhooks[count.index]]
19+
}
20+
21+
data "pagerduty_vendor" "sumologic" {
22+
name = "Sumo Logic"
23+
}
24+
25+
# Generate timestamp to add to the folder name.
26+
locals {
27+
time_stamp = formatdate("DD-MMM-YYYY hh:mm:ss", timestamp())
28+
}
29+
30+
# Install Pagerduty App
31+
resource "null_resource" "install_pagerduty_app" {
32+
depends_on = [sumologic_http_source.pagerduty]
33+
triggers = {
34+
version = var.app_version
35+
}
36+
37+
provisioner "local-exec" {
38+
command = <<EOT
39+
curl -s --request POST '${var.sumo_api_endpoint}/v1/apps/589857e0-e4c1-4165-8212-f656899a3b95/install' \
40+
--header 'Accept: application/json' \
41+
--header 'Content-Type: application/json' \
42+
-u ${var.sumo_access_id}:${var.sumo_access_key} \
43+
--data-raw '{ "name": "Pagerduty V2 - ${local.time_stamp}", "description": "The Sumo Logic App for PagerDuty V2 collects incident messages from your PagerDuty account via a webhook, and displays that incident data in pre-configured Dashboards, so you can monitor and analyze the activity of your PagerDuty account and Services.", "destinationFolderId": "${var.folder_id}","dataSourceValues": {"logsrcpd": "_sourceCategory = ${var.source_category}"}}'
44+
EOT
45+
}
46+
}

pagerduty/versions.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
terraform {
2+
required_version = ">= 0.13.0"
3+
4+
required_providers {
5+
null = {
6+
version = "~> 2.1"
7+
}
8+
pagerduty = {
9+
source = "pagerduty/pagerduty"
10+
version = "~> 1.7"
11+
}
12+
sumologic = {
13+
version = "~> 2.1.0"
14+
source = "SumoLogic/sumologic"
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)