PagerDuty / terraform-provider-pagerduty

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

pagerduty_schedule with teams gets huge changes on team updates #644

Open hryamzik opened 1 year ago

hryamzik commented 1 year ago

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Configuration Files

resource "pagerduty_schedule" "this" {
<...>
teams = [pagerduty_team.this.id, module.this.team_id]

Expected Behavior

No deletions

Actual Behavior

  # pagerduty_schedule.this will be updated in-place
~ resource "pagerduty_schedule" "this" {
        id             = "P******"
        name           = "Schedule"
      ~ teams          = [
          - "P******",
            "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          - "P******",
          + "P******",
        ]
        # (3 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Steps to Reproduce

  1. Create pagerduty_schedule resource based on groups
  2. apply
  3. define another user for any of groups
  4. plan

Extra notes

PD setup is fine after apply, just the plan looks scary and difficult to verify.

SamuelNorbury commented 1 year ago

This is due to the teams that users are in, that are added to the schedule. In other words, if the schedule contains users from team a, b, c, then pagerduty will (on their side, outside of the management of terraform) edit the schedule to include those teams. So a solution is to manually add the teams to the schedule yourself.

A followup problem is: pagerduty then sort the teams by team name. So even if you add all the teams, you will get proposed ordering changes on every plan.

egarbi commented 1 year ago

This seems to be a duplicate of https://github.com/PagerDuty/terraform-provider-pagerduty/issues/404