terraform-provider-pagerduty
terraform-provider-pagerduty copied to clipboard
Schedule's Teams' IDs (ordering?) recurring replace
PagerDuty v3.23.1
When you get the state of a schedule that is related to multiple teams, I believe the team IDs are ordered. This causes issues when comparing expected state to current state.
Our TF Code:
resource "pagerduty_schedule" "pd_sched_gmic_helios_schedule1" { ..... teams = [pagerduty_team.team1.id, pagerduty_team.team2.id] }
Every plan/apply we get this: # pagerduty_schedule.pd_schedudule will be updated in-place ~ resource "pagerduty_schedule" "pd_schedudule" { id = "P2W357J" name = "ScheduleName" ~ teams = [ - "P8KOKBP", "PUCXHGT", + "P8KOKBP", ] # (3 unchanged attributes hidden)
# (1 unchanged block hidden)
}
AWS Provider had a similar issue here: https://stackoverflow.com/questions/68870558/make-terraform-ignore-the-order-of-list-items-returned-from-the-service
adding to schedule block: depends_on = [ pagerduty_team.team1, pagerduty_team.team2 ]
Identical Result:
pagerduty_schedule.pd_schedudule will be updated in-place
~ resource "pagerduty_schedule" "pd_schedudule" { id = "P2W357J" name = "ScheduleName" ~ teams = [
- "P8KOKBP", "PUCXHGT",
- "P8KOKBP", ]
(3 unchanged attributes hidden)
I'm pretty confident this is an API 'ordering' issue that is breaking like the AWS Provider referenced above.
I've 100% confirmed the issue is the way the GET call to the TF API is returning 'sorted' values.
previously we had two instances. one worked and one didn't. We reordered the teamId in "teams array" (shown below). and the two instances flipped. one was failing, then worked, two was working, then failed.
I believe this will fix the error in the short-term: teams = sort([pagerduty_team.teams1.id, team2.id ])
I believe the long-term fix is a provider update to sort the array locally by ID when calculating expected state so that when comparing to 'current state' the order of IDs are consistent.
Sort() didn't fix it. This needs to be fixed.
pagerduty_schedule.pd_sched_escalation will be updated in-place
~ resource "pagerduty_schedule" "pd_sched_escalation" {
id = "P1W1DX3"
name = "Escalation"
~ teams = [
- "PJL7BVI",
"PCCYA45",
+ "PJL7BVI",
]
# (3 unchanged attributes hidden)
# (1 unchanged block hidden)
}