PagerDuty / terraform-provider-pagerduty

Terraform PagerDuty provider
https://www.terraform.io/docs/providers/pagerduty/
Mozilla Public License 2.0
204 stars 212 forks source link

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

Open sterfield opened 3 years ago

sterfield commented 3 years ago

Terraform Version

1.0.5

Affected Resource(s)

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:

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

Thanks for your help !

sgujavarthy commented 2 years ago

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

podon commented 2 years ago

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