terraform-provider-pagerduty icon indicating copy to clipboard operation
terraform-provider-pagerduty copied to clipboard

`pagerduty_schedule` allows `teams` at creation but not for modification

Open sterfield opened this issue 3 years ago • 2 comments

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

  1. create a pagerduty_schedule without any teams
  2. assign this schedule to an escalation policy, then the escalation to a team
  3. this will add the team to the schedule
  4. issue a terraform plan. It'll want to remove the team
  5. issue a terraform apply. It'll be successful
  6. 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 !

sterfield avatar Oct 07 '21 13:10 sterfield

@stmcallister is this going to be addressed? We too are getting into this permanent diff (code deviating from actual state)

sgujavarthy avatar Mar 04 '22 16:03 sgujavarthy

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

podon avatar Jun 23 '22 07:06 podon