Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removal of user with dependencies fails #66

Closed
jufemaiz opened this issue Feb 20, 2018 · 5 comments
Closed

Removal of user with dependencies fails #66

jufemaiz opened this issue Feb 20, 2018 · 5 comments

Comments

@jufemaiz
Copy link
Contributor

jufemaiz commented Feb 20, 2018

Terraform Version

v0.11.3

Affected Resource(s)

Please list the resources as a list, for example:

  • pagerduty_user
  • pagerduty_schedule
  • pagerduty_escalation_policy

Terraform Configuration Files

This one is a little hard due to the structure. In simple form, we had:

  • an array of pagerduty_users
  • a pagerduty_schedule that the users were members of
  • two pagerduty_escalation_policies that referenced the pagerduty_schedule

Debug Output

Plan:

------------------------------------------------------------------------
  |  
  | An execution plan has been generated and is shown below.
  | Resource actions are indicated with the following symbols:
  | ~ update in-place
  | - destroy
  |  
  | Terraform will perform the following actions:
  |  
  | ~ pagerduty_escalation_policy.blah0
  | rule.1.target.#:                    "4" => "3"
  | rule.1.target.3.id:                 "XXXXXX0" => ""
  |  
  | ~ pagerduty_escalation_policy.blah1
  | rule.#:                             "2" => "1"
  | rule.1.escalation_delay_in_minutes: "30" => "0"
  | rule.1.target.#:                    "1" => "0"
  | rule.1.target.0.id:                 "XXXXXX1" => ""
  |  
  | ~ pagerduty_escalation_policy.blah2
  | rule.1.target.#:                    "4" => "3"
  | rule.1.target.3.id:                 "XXXXXX0" => ""
  |  
  | ~ pagerduty_escalation_policy.blah3
  | rule.#:                             "2" => "1"
  | rule.1.escalation_delay_in_minutes: "30" => "0"
  | rule.1.target.#:                    "1" => "0"
  | rule.1.target.0.id:                 "XXXXXX1" => ""
  |  
  | ~ module.pagerduty.pagerduty_schedule.on_call_shift
  | layer.0.users.#:                    "4" => "3"
  | layer.0.users.2:                    "XXXXXX0" => "XXXXXX2"
  | layer.0.users.3:                    "XXXXXX2" => ""
  |  
  | - module.pagerduty.pagerduty_user.devops[3]

Expected Behavior

  • User is able to be destroyed when the relevant dependencies are deleted as part of the terraform plan to be applied.

Actual Behavior

  • User failed to be deleted as dependencies were not destroyed first (and were part of the plan).
module.pagerduty.pagerduty_user.devops[3]: Destroying... (ID: XXXXXX0)
  |  
  | Error: Error applying plan:
  |  
  | 1 error(s) occurred:
  |  
  | * module.pagerduty.pagerduty_user.devops[3] (destroy): 1 error(s) occurred:
  |  
  | * pagerduty_user.devops.3: DELETE API call to https://api.pagerduty.com/users/XXXXXX0 failed 400 Bad Request. Code: 0, Errors: [The user cannot be deleted as they have 2 escalation policies and 1 schedule. Please remove the user from the following escalation policies and remove the user from the following schedule to continue.], Message:
@roccomuscaritolo-okta
Copy link

This is also effecting us. Having to have 20 repeated pagerduty_team_membership resources is kinda crazy. So we attempted to use count.

However, if you test removing a user from the middle of the list that terraform count iterates over, it shifts the rest of the entries down one index and forces new resources to be made for each.

And this process fails, because terraform tries to remove the user(s) from the Nth count and re-add it in Nth - 1 while it is still a member of the scheduled rotations...

pagerduty_team_membership and terraform counts don't work. We need it to be a list.

@stmcallister
Copy link
Contributor

Hello! #258 should have addressed this. Please post again if that's not the case.

@jufemaiz
Copy link
Contributor Author

Thanks for the update @stmcallister !

Sadly in the interim I've left the company that I was at when trying to make use of it and that company subsequently went under. Can't test this personally.

@evanrappe
Copy link

@stmcallister, have you heard from anyone on this issue since last year? Seem to still be experiencing it when attempting to remove a user, team membership, schedule. I haven't tested a ton of scenarios but it seems to maybe hit a snag when an escalation policy references a schedule.

...failed 400 Bad Request. Code: 2001, Errors: [User cannot be removed as they belong to an escalation policy on this team]

@frek818
Copy link

frek818 commented Jul 1, 2022

I also have this issue. Any solutions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants