PagerDuty / terraform-provider-pagerduty

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

Errors when trying to apply a business service that was manually deleted from PD #895

Open grzegorzpro opened 1 week ago

grzegorzpro commented 1 week ago

When a business service is manually deleted from PagerDuty, but not from the configuration, Terraform provider should restore the business service during the next apply. Unfortunately, it seems that the provider is not able to handle such cases and raises errors shown below.

Terraform Version

Terraform v1.8.5 on linux_amd64

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Configuration Files

resource "pagerduty_business_service" "example" {
  name             = "Example Business Service"
  description      = "Test description"
}

Debug Output

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Error reading Business Service 
│ 
│   with pagerduty_business_service.example,
│   on service.tf line 1, in resource "pagerduty_business_service" "example":
│    1: resource "pagerduty_business_service" "example" {
│ 
│ Could not decode JSON response: json: cannot unmarshal array into Go value
│ of type pagerduty.BusinessService
╵

Expected Behavior

Terraform plans to create the business service since it does not exist.

Actual Behavior

Terraform exits after a lenghty wait with the error shown above.

Steps to Reproduce

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

  1. terraform apply to create the business service
  2. Manually delete the business service in PagerDuty
  3. Change anything in the configuration (e.g. the business service description)
  4. terraform apply again