PagerDuty / terraform-provider-pagerduty

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

Schedule overrides are lost after terraform apply #817

Open NargiT opened 8 months ago

NargiT commented 8 months ago

Terraform Version

Terraform v1.5.7 on linux_amd64 We cannot upgrade to 1.7.2 because there is incompatibility between our S3 implementation and how terraform handles it. In any case, the issue concerne the provider. Provider version 3.7.0

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Configuration Files

resource "pagerduty_user" "user1" {
  email     = "user1@foo.ch"
  name     = "user one"
  role      = "admin"
}
resource "pagerduty_user" "user2" {
  email     = "user2@foo.ch"
  name      = "user two"
  role      = "admin"
}

resource "pagerduty_team" "team" {
  name = "team"
}

resource "pagerduty_team_membership" "member_1" {
  team_id = pagerduty_team.team.id
  user_id = pagerduty_user.user1.id
  role = "manager"
}

resource "pagerduty_team_membership" "member_2" {
  team_id = pagerduty_team.team.id
  user_id = pagerduty_user.user2.id
  role = "manager"
}

resource "pagerduty_schedule" "team" {
  name = "team schedule"
  description = "Created by Terraform, maintained manually"
  time_zone = "Europe/Berlin"
  layer {
    # every 7 day
    rotation_turn_length_seconds = 1209600
    # start from monday
    rotation_virtual_start = "2021-07-05T02:00:00+02:00"
    start = "2021-04-05T00:00:00Z"
    users = [pagerduty_user1.id, pagerduty_user2.id]

    restriction {
      duration_seconds = 36000
      start_time_of_day = "08:30:00"
      type = "weekly_restriction"
      start_day_of_week = 1
    }
    restriction {
      duration_seconds = 36000
      start_time_of_day = "08:30:00"
      type = "weekly_restriction"
      start_day_of_week = 2
    }
  }
  lifecycle {
    ignore_changes = [
      layer["start"],
      layer["rotation_turn_length_seconds"]
    ]
  }
}

Expected Behavior

The web site should keep the override

Actual Behavior

Override is available in website, by not active anymore

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply
  2. go to pager duty and add an override of user1 on user2
  3. run terraform apply
  4. go back to the schedule, overide is present but not applied

Important Factoids

Nothing special

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

tovbinm commented 6 months ago

Same. Is there a workaround??

NargiT commented 4 months ago

Same. Is there a workaround??

ignoring teams in the lifecycle avoid removing and adding member to a team.

JoaquinPretell92 commented 2 months ago

override and schedule are different, you are creating a schedule with restrictions and i understand you are creating overrides over your schedule becuase some users need to be replace on vacations, PTO, etc. The reason the overrides get deleted becuase they are not part of the code so the state doesnt recognize them, the state check them as manual configurations so it deletes them. But why are you reapplying your code.

NargiT commented 2 months ago

. But why are you reapplying your code.

@JoaquinPretell92 with have an automated system that sync users from active directory. So new employee are added and old are removed.

The reason the overrides get deleted becuase they are not part of the code so the state doesnt recognize them, the state check them as manual configurations so it deletes them

Then why I can still see them on the web site ? There is a bug IMHO.