-
-
Save tratnayake/108f42e1897884ae5c7783373595d946 to your computer and use it in GitHub Desktop.
pd_terraform_example_new
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
locals { | |
my_team_subteam_a_members = toset([ | |
pagerduty_user.thilina_ratnayake.id, | |
pagerduty_user.teammate_b.id, | |
pagerduty_user.teammate_c.id, | |
]) | |
my_team_subteam_b_members = toset([ | |
pagerduty_user.teammate_a.id, | |
pagerduty_user.teammate_d.id | |
]) | |
} | |
resource "pagerduty_schedule" "myteam_schedule" { | |
name = "My Team" | |
time_zone = "America/Los_Angeles" | |
description = "PD Schedule for My Team, Slack #my-team, Email: my-team@company.com" | |
layer { | |
name = "weekday" | |
rotation_turn_length_seconds = 1209600 | |
rotation_virtual_start = "2023-01-1T09:00:00-08:00" | |
start = "2023-01-1T09:00:00-08:00" | |
users = setunion(local.my_team_subteam_a_members, local.my_team_subteam_b_members) | |
} | |
} | |
resource "pagerduty_escalation_policy" "myteam_escalation" { | |
name = "My Team's escalation policy for all services owned by My-Team" | |
num_loops = 9 | |
# First Notify | |
rule { | |
target { | |
type = "schedule_reference" | |
id = pagerduty_schedule.myteam_schedule.id | |
} | |
escalation_delay_in_minutes = 10 # How long to wait before escalating | |
} | |
# Escalate if not ack'd | |
rule { | |
target { | |
type = "schedule_reference" | |
id = pagerduty_schedule.otherteam_schedule.id | |
} | |
} | |
} | |
resource "pagerduty_service" "my_service_prod" { | |
name = "My-Service PROD" | |
escalation_policy = pagerduty_escalation_policy.myteam_escalation.id | |
} | |
resource "pagerduty_team_membership" "my_team_subteam_a_members" { | |
for_each = local.my_team_subteam_a_members | |
user_id = each.value | |
team_id = pagerduty_team.my_team_subteam_a.id | |
} | |
resource "pagerduty_team_membership" "my_team_subteam_b_members" { | |
for_each = local.my_team_subteam_b_members | |
user_id = each.value | |
team_id = pagerduty_team.my_team_subteam_b.id | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment