Skip to content

Commit 75ce64c

Browse files
authored
Merge pull request #1 from SumoLogic/github_pagerduty
Added Github and Pagerduty Modules
2 parents 7dfc3f4 + 42ae484 commit 75ce64c

File tree

11 files changed

+440
-6
lines changed

11 files changed

+440
-6
lines changed

README.md

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,42 @@ Configure Sumo Logic Applications and Connections using Terraform modules.
44
The modules configure/create the following resources:
55
- A source under the specified collector for the integration in Sumo Logic.
66
- App dashboards in the specified folder in Sumo Logic.
7-
- Webhook configurations in JIRA, Bitbucket or other chosen systems.
7+
- Connections in Sumo Logic.
8+
- Webhook configurations in JIRA, Bitbucket, Pagerduty or other chosen systems.
9+
- Resources in cloud systems such as AWS.
810

911
## Getting Started
1012

1113
#### Requirements
1214

1315
* [Terraform 0.13+](https://www.terraform.io/downloads.html)
1416
* [curl](https://curl.haxx.se/download.html) for App installations.
17+
* [Sumo Logic Terraform Provider](https://registry.terraform.io/providers/SumoLogic/sumologic/latest)
18+
* [Null Terraform Provider](https://registry.terraform.io/providers/hashicorp/null/latest).
19+
* Respective Terraform providers based on selections.
20+
21+
Create a `providers.tf` file and add the requirements in the following format:
22+
23+
```shell
24+
terraform {
25+
required_version = ">= 0.13"
26+
27+
required_providers {
28+
null = {
29+
version = "~> 2.1"
30+
}
31+
sumologic = {
32+
source = "sumologic/sumologic"
33+
version = "~> 2.1.0"
34+
}
35+
jira = {
36+
source = "fourplusone/jira"
37+
version = "~> 0.1.14"
38+
}
39+
40+
}
41+
}
42+
```
1543

1644
#### Sumo Logic Provider
1745

@@ -49,8 +77,8 @@ Configure the collector resource as below:
4977
5078
```shell
5179
resource "sumologic_collector" "sumo_collector" {
52-
name = "SumoLogic Atlassian"
53-
category = "Atlassian"
80+
name = "SumoLogic Integrations"
81+
category = "SumoLogic"
5482
}
5583
```
5684
@@ -61,8 +89,8 @@ Configure a folder as below:
6189
```shell
6290
data "sumologic_personal_folder" "personalFolder" {}
6391
resource "sumologic_folder" "folder" {
64-
name = "SumoLogic Atlassian"
65-
description = "SumoLogic Atlassian Applications"
92+
name = "SumoLogic Applications"
93+
description = "SumoLogic Applications Folder"
6694
parent_id = data.sumologic_personal_folder.personalFolder.id
6795
depends_on = [sumologic_collector.sumo_collector]
6896
}
@@ -105,4 +133,9 @@ See respective module readme and examples for more details.
105133
- Sumo Logic Connections
106134
- [Jira Cloud](https://github.com/SumoLogic/terraform-sumologic-integrations/tree/master/atlassian/webhooks/sumologic_jira_cloud)
107135
- [Jira Server](https://github.com/SumoLogic/terraform-sumologic-integrations/tree/master/atlassian/webhooks/sumologic_jira_server)
108-
- [Jira Service Desk](https://github.com/SumoLogic/terraform-sumologic-integrations/tree/master/atlassian/webhooks/sumologic_jira_service_desk)
136+
- [Jira Service Desk](https://github.com/SumoLogic/terraform-sumologic-integrations/tree/master/atlassian/webhooks/sumologic_jira_service_desk)
137+
- AWS
138+
- [CloudTrail](https://github.com/SumoLogic/terraform-sumologic-integrations/tree/master/aws/cloudtrail)
139+
- [Github](https://github.com/SumoLogic/terraform-sumologic-integrations/tree/master/github)
140+
- [Pagerduty](https://github.com/SumoLogic/terraform-sumologic-integrations/tree/master/pagerduty)
141+

examples/github.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
provider "github" {
2+
token = "<GITHUB_TOKEN>"
3+
organization = "<GITHUB_ORGANIZATION"
4+
}
5+
6+
### Github Module
7+
module "sumologic-jira-github-app" {
8+
source = "SumoLogic/integrations/sumologic//github"
9+
version = "{revision}"
10+
11+
sumo_access_id = "<SUMO_ACCESS_ID>"
12+
sumo_access_key = "<SUMO_ACCESS_KEY>"
13+
sumo_api_endpoint = "https://api.sumologic.com/api/v1/"
14+
collector_id = sumologic_collector.sumo_collector.id
15+
source_category = "Github"
16+
folder_id = sumologic_folder.folder.id
17+
github_repo_webhook_create = "true"
18+
github_org_webhook_create = "true"
19+
github_repository_names = ["<GITHUB_REPOSITORY_NAME1>", "<GITHUB_REPOSITORY_NAME2"]
20+
github_repo_events = ["create","delete","fork"] # By default all events are configured.
21+
github_org_events = ["create","delete","fork"] # By default all events are configured.
22+
app_version = "1.0"
23+
}

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: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Github
2+
3+
## Purpose
4+
5+
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.
6+
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+
9+
## Requirements
10+
11+
* [Terraform](https://www.terraform.io/downloads.html) >= 0.13.0
12+
* Null >= 2.1
13+
* Github >= 2.8
14+
15+
## Module Declaration
16+
17+
This module requires Sumo Logic collector Id and Folder id as explained [here](https://github.com/SumoLogic/terraform-sumologic-integrations#prerequisites-for-using-modules).
18+
19+
### Github Provider
20+
```shell
21+
provider "github" {
22+
token = "<GITHUB_TOKEN>"
23+
organization = "<GITHUB_ORGANIZATION"
24+
}
25+
```
26+
27+
### Github Module
28+
```shell
29+
module "sumologic-jira-github-app" {
30+
source = "SumoLogic/integrations/sumologic//github"
31+
version = "{revision}"
32+
33+
sumo_access_id = "<SUMO_ACCESS_ID>"
34+
sumo_access_key = "<SUMO_ACCESS_KEY>"
35+
sumo_api_endpoint = "https://api.sumologic.com/api/v1/"
36+
collector_id = sumologic_collector.sumo_collector.id
37+
source_category = "Github"
38+
folder_id = sumologic_folder.folder.id
39+
github_repo_webhook_create = "true"
40+
github_org_webhook_create = "true"
41+
github_repository_names = ["<GITHUB_REPOSITORY_NAME1>", "<GITHUB_REPOSITORY_NAME2"]
42+
github_repo_events = ["create","delete","fork"] # By default all events are configured.
43+
github_org_events = ["create","delete","fork"] # By default all events are configured.
44+
app_version = "1.0"
45+
}
46+
```
47+
48+
## Inputs
49+
50+
| Name | Description | Type | Default | Required |
51+
|------|-------------|------|---------|:-----:|
52+
|sumo_access_id|[Sumo Logic Access ID](https://help.sumologic.com/Manage/Security/Access-Keys)|string| |yes
53+
|sumo_access_key|[Sumo Logic Access Key](https://help.sumologic.com/Manage/Security/Access-Keys)|string| |yes
54+
|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
55+
|collector_id|Sumo Logic Collector ID|string| |yes
56+
|folder_id|Sumo Logic Folder ID|string| |yes
57+
|source_category|Github Source Category|string|Github|yes
58+
|github_token|[Github Token.](https://github.com/settings/tokens)|string| |yes
59+
|github_repo_webhook_create|Create webhooks at repo level. Default "true".|string|true|no
60+
|github_org_webhook_create|Create webhooks at org level. Default "false".|string|false|no
61+
|github_organization|Organization Name.|string| |yes
62+
|github_repository_names|List of repository names for which webhooks need to be created. Example, ["repo1","repo2"]|list| |yes
63+
|github_repo_events|List of repository [events](https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads) which should be sent to Sumo Logic. Example, ["create","delete","fork"]|list|List of all the Github Repo Events|yes
64+
|github_org_events|List of organization level [events](https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads) which should be sent to Sumo Logic. Example, ["create","delete","fork"]|string|List of all the Github Org Events|yes
65+
|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

github/inputs.tf

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Github
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 Github Source Category"
22+
default = "Github"
23+
}
24+
variable "folder_id" {
25+
type = string
26+
description = "Sumo Logic Content Folder ID"
27+
}
28+
variable "github_repository_names" {
29+
type = list
30+
description = "Github Repositories"
31+
default = []
32+
}
33+
variable "github_repo_events" {
34+
type = list
35+
description = "Github Repository Events"
36+
default = ["check_run", "check_suite", "commit_comment", "create", "delete", "deploy_key", "deployment",
37+
"deployment_status", "fork",
38+
"gollum", "issue_comment", "issues", "label", "member", "meta", "milestone", "package", "page_build", "ping", "project_card",
39+
"project_column", "project", "public", "pull_request", "pull_request_review", "pull_request_review_comment",
40+
"push", "release", "repository", "repository_import", "repository_vulnerability_alert", "star", "status", "team_add", "watch"]
41+
}
42+
variable "github_org_events" {
43+
type = list
44+
description = "Github Organization Events"
45+
default = ["check_run", "check_suite", "commit_comment", "create", "delete", "deploy_key", "deployment",
46+
"deployment_status", "fork", "gollum", "issue_comment", "issues", "label", "member",
47+
"membership", "meta", "milestone", "organization", "org_block", "package", "page_build", "ping", "project_card",
48+
"project_column", "project", "public", "pull_request", "pull_request_review", "pull_request_review_comment",
49+
"push", "release", "repository", "repository_import", "repository_vulnerability_alert", "star", "status", "team", "team_add", "watch"]
50+
}
51+
variable "github_org_webhook_create" {
52+
type = string
53+
description = "Create Webhooks at Organization Level"
54+
default = "false"
55+
}
56+
variable "github_repo_webhook_create" {
57+
type = string
58+
description = "Create Webhooks at Repository Level"
59+
default = "true"
60+
}
61+
variable "app_version" {
62+
type = string
63+
description = "App Version"
64+
default = "1.0"
65+
}

github/main.tf

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Create/Delete Github Source
2+
resource "sumologic_http_source" "github" {
3+
name = "Github"
4+
category = var.source_category
5+
fields = { "_convertHeadersToFields" = "true" }
6+
collector_id = var.collector_id
7+
}
8+
9+
# Repository Level Webhook
10+
resource "github_repository_webhook" "github_sumologic_repo_webhook" {
11+
count = "${var.github_repo_webhook_create}" ? length(var.github_repository_names) : 0
12+
repository = var.github_repository_names[count.index]
13+
14+
configuration {
15+
url = sumologic_http_source.github.url
16+
content_type = "json"
17+
insecure_ssl = false
18+
}
19+
20+
active = true
21+
22+
events = var.github_repo_events
23+
}
24+
25+
# Organization Level Webhook
26+
resource "github_organization_webhook" "github_sumologic_org_webhook" {
27+
count = "${var.github_org_webhook_create}" ? 1 : 0
28+
29+
configuration {
30+
url = sumologic_http_source.github.url
31+
content_type = "json"
32+
insecure_ssl = false
33+
}
34+
35+
active = true
36+
37+
events = var.github_org_events
38+
}
39+
40+
# Generate timestamp to add to the folder name.
41+
locals {
42+
time_stamp = formatdate("DD-MMM-YYYY hh:mm:ss", timestamp())
43+
}
44+
45+
# Install Github App
46+
resource "null_resource" "install_github_app" {
47+
depends_on = [sumologic_http_source.github]
48+
triggers = {
49+
version = var.app_version
50+
}
51+
52+
provisioner "local-exec" {
53+
command = <<EOT
54+
curl -s --request POST '${var.sumo_api_endpoint}/v1/apps/86289912-b909-426e-8154-bda55b9ee902/install' \
55+
--header 'Accept: application/json' \
56+
--header 'Content-Type: application/json' \
57+
-u ${var.sumo_access_id}:${var.sumo_access_key} \
58+
--data-raw '{ "name": "Github - ${local.time_stamp}", "description": "The Sumo Logic App for GitHub connects to your GitHub repository at the Organization or Repository level, and ingests GitHub events via a webhook.", "destinationFolderId": "${var.folder_id}","dataSourceValues": {"paramId123": "_sourceCategory = ${var.source_category}"}}'
59+
EOT
60+
}
61+
}

github/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+
github = {
9+
source = "hashicorp/github"
10+
version = "~> 2.8"
11+
}
12+
sumologic = {
13+
version = "~> 2.1.0"
14+
source = "SumoLogic/sumologic"
15+
}
16+
}
17+
}

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.7
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"]
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

0 commit comments

Comments
 (0)