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

Cannot delete team with existing Schedules association(s)

Open m1n9o opened this issue 3 years ago • 4 comments

Terraform Version

0.15.5

Affected Resource(s)

Please list the resources as a list, for example:

  • team
  • schedule

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

The problem is much straightforward. I created a team with escalation policy and services. I removed the escalation policy and services with terraform apply. After that, when I try to remove the team. It says cannot delete team with existing schedules association(s). It's quite annoying if we need to disassociate them manually.

Panic Output

[2021-07-20T08:26:25Z] Error: DELETE API call to https://api.pagerduty.com/teams/P2WMR52 failed 400 Bad Request. Code: 6006, Errors: [Cannot delete team with existing Schedules association(s)], Message: Team has existing associations.

Expected Behavior

It should be able to remove the team.

Steps to Reproduce

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

  1. terraform apply

m1n9o avatar Jul 20 '21 08:07 m1n9o

it's limitation on pager duty. Since the schedule is linked to the team, you cannot delete the team. you need to first delete the schedule then the team.

maybe you can used depends_on feature so terraform will first delete that perticular schedule before the team.

NargiT avatar Aug 02 '21 14:08 NargiT

it's limitation on pager duty. Since the schedule is linked to the team, you cannot delete the team. you need to first delete the schedule then the team.

maybe you can used depends_on feature so terraform will first delete that perticular schedule before the team.

Why not just disassociate them so that terraform can destroy it. And keep the schedule at the same time. Schedule should not be deleted and re-created that often.

m1n9o avatar Aug 05 '21 06:08 m1n9o

This is also an issue for me, I've tried configuring the depends_on in a variety of ways but couldn't get it to work. Ended up having to delete manually through the UI; would be great to be able to delete through TF!

edobry avatar Sep 07 '21 18:09 edobry

What is funny is that you can create a schedule only if a responder is assign to it. but if you delete the user, the schedule still exists and a "shadow user take it's place". Feels like core design issues IMO. This make terraform a bit more tricky to use.

NargiT avatar Oct 13 '21 08:10 NargiT

@m1n9o @NargiT @edobry An update for fixing this issue was merged on #561 and It has been released in version v2.6.1 of PagerDuty TF Provider, so updating to the new version hopefully You all would be able to gracefully delete Schedules without getting stuck with into this error. Please if You find any further issues related with this error after updating don't hesitate on reopening this Issue ✌🏽

imjaroiswebdev avatar Aug 25 '22 21:08 imjaroiswebdev

@imjaroiswebdev there are still two use cases. one will be solved in #564 and one is when the schedule is the only remaining one in an escalation policy.

drastawi avatar Sep 06 '22 08:09 drastawi

Great I will start to include Team's ownership now in our production version !

NargiT avatar Sep 30 '22 11:09 NargiT