Address Schedule can't be deleted when used by EP with one layer configured #693
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This update is meant to solve two issues:
Issue 1
When there is a configuration that includes a
pagerduty_schedule
being used by anpagerduty_escalation_policy
in its only one configured layer and happen that the Schedule is try to be destroyed, Terraform will return the following error...╷ │ Error: DELETE API call to https://api.pagerduty.com/schedules/PSAZ43T failed 400 Bad Request. Code: 2001, Errors: [Schedule can't be deleted if it's being used by escalation policies], Message: Invalid Input Provided │
Regardless of whether you are updating the reference to the Schedule this error will be blocking the deletion, because of the order in which the update and deletion operations are sorted by Terraform based on the dependency between the Schedule and EP.
Issue 2
When there is a configuration that includes a
pagerduty_schedule
being used by anpagerduty_escalation_policy
with multiple layers but the same Schedule is the only configured target on each layer and happen that the Schedule is try to be destroyed, The Provider will panic with the following error...Test cases introduced...