terraform-provider-pagerduty
terraform-provider-pagerduty copied to clipboard
`pagerduty_schedule` allows `teams` at creation but not for modification
Terraform Version
1.0.5
Affected Resource(s)
-
pagerduty_schedule
A recent PR allowed to add teams
to a pagerduty_schedule
.
However, if you look at the documentation, the API is reacting in two different ways:
- If you create a schedule, you can attach teams to it
- if you modify a schedule, you cannot update teams
Documentation states also that if you "like to assign a team to your schedule, add your schedule to an escalation policy and then add that escalation policy to your team."
The API is also showing a teams
object you can feed for a POST or a PUT, even if it will be ignored in the latter.
Expected Behavior
Having No Changes
from Terraform if you modify a schedule with teams that are not already attached to the said schedule.
Actual Behavior
Terraform will always try to add / remove teams according to what is written in the code on an already-existing schedule, but as the API doesn't allow it to do any modification regarding teams, it'll always report permanent diff.
Steps to Reproduce
- create a
pagerduty_schedule
without any teams - assign this schedule to an escalation policy, then the escalation to a team
- this will add the team to the schedule
- issue a
terraform plan
. It'll want to remove the team - issue a
terraform apply
. It'll be successful - issue a
terraform plan
, it'll still want to remove the team
Important Factoids
I realised that the problem relies more on the Pagerduty API that have a different behavior between a POST and a PUT, but the direct consequence is that many users will face a permanent diff OR will have to constantly update the teams
parameter in their pagerduty_schedule
in order to have a stable plan.
References
- #368
Thanks for your help !
@stmcallister is this going to be addressed? We too are getting into this permanent diff (code deviating from actual state)
Hit this issue today. For anyone else experiencing this, take a look at https://community.pagerduty.com/forum/t/how-to-remove-a-team-that-has-an-associated-schedule/2117/2