-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: adding opsgenie --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
ddea46f
commit b49aa19
Showing
6 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
locals { | ||
users_set = toset(var.users) | ||
cluster_environments_set = toset(var.cluster_environments) | ||
time_zone = "Africa/Monrovia" | ||
} | ||
|
||
data "opsgenie_user" "users" { | ||
for_each = local.users_set | ||
username = each.key | ||
} | ||
|
||
resource "opsgenie_team" "teams" { | ||
for_each = local.cluster_environments_set | ||
|
||
name = "${var.company_key}-${each.value}-team" | ||
description = "This is for company ${var.company_key} in the ${each.value} environment" | ||
delete_default_resources = true | ||
|
||
dynamic "member" { | ||
for_each = data.opsgenie_user.users | ||
|
||
content { | ||
id = member.value.id | ||
role = "user" | ||
} | ||
} | ||
} | ||
|
||
resource "opsgenie_team_routing_rule" "routing_rules" { | ||
for_each = local.cluster_environments_set | ||
|
||
name = "${var.company_key}-${each.value}-routing-rule" | ||
team_id = opsgenie_team.teams[each.key].id | ||
order = 0 | ||
timezone = local.time_zone | ||
criteria { | ||
type = "match-all" | ||
} | ||
notify { | ||
name = opsgenie_schedule.schedules[each.key].name | ||
type = "schedule" | ||
} | ||
|
||
} | ||
|
||
resource "opsgenie_schedule" "schedules" { | ||
for_each = local.cluster_environments_set | ||
|
||
name = "${var.company_key}-${each.value}-schedule" | ||
description = "This is for company ${var.company_key} in the ${each.value} environment" | ||
timezone = local.time_zone | ||
owner_team_id = opsgenie_team.teams[each.key].id | ||
enabled = true | ||
} | ||
|
||
resource "opsgenie_schedule_rotation" "rotations" { | ||
for_each = local.cluster_environments_set | ||
|
||
schedule_id = opsgenie_schedule.schedules[each.key].id | ||
name = "${var.company_key}-${each.value}-rotation" | ||
|
||
dynamic "participant" { | ||
for_each = data.opsgenie_user.users | ||
|
||
content { | ||
type = "user" | ||
id = participant.value.id | ||
} | ||
} | ||
|
||
start_date = "2023-03-14T09:00:00Z" # Set the start date and time for the rotation | ||
type = "weekly" | ||
length = 1 | ||
} | ||
|
||
resource "opsgenie_api_integration" "prometheus" { | ||
for_each = local.cluster_environments_set | ||
name = "${var.company_key}-${each.value}-prometheus-api-int" | ||
type = "API" | ||
|
||
responders { | ||
type = "team" | ||
id = opsgenie_team.teams[each.key].id | ||
} | ||
|
||
enabled = true | ||
allow_write_access = true | ||
ignore_responders_from_payload = true | ||
suppress_notifications = false | ||
owner_team_id = opsgenie_team.teams[each.key].id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
terraform { | ||
required_providers { | ||
opsgenie = { | ||
source = "opsgenie/opsgenie" | ||
version = "0.6.20" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
variable "users" { | ||
description = "List of user email addresses" | ||
type = list(string) | ||
} | ||
|
||
variable "company_key" { | ||
description = "Unique identifier for the company" | ||
type = string | ||
} | ||
|
||
variable "cluster_environments" { | ||
description = "List of cluster environment names" | ||
type = list(string) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module "opsgenie_teams" { | ||
source = "./modules/opsgenie/0.1.0" | ||
users = var.opsgenie_emails | ||
company_key = var.company_key | ||
cluster_environments = var.cluster_environments | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters