Importing PagerDuty resources in-place with Terraform

Hello,

I’m trying to import schedules, escalation policies and event rules through Terraform. For reasons that I’m not sure about, it seems that the PagerDuty provider is forcing all resources to be destroyed and recreated instead of being updated in-place. Am I doing something wrong or is this not possible? Thank you!

Hi John,

You can import schedules, escalation policy, and event rules using Terraform. The terraform documentation provides examples on how to import those here: https://registry.terraform.io/providers/PagerDuty/pagerduty/latest/docs

Thanks,

Abbott Brannon
Tech Support Specialist

I’m follow those examples but I still end up with resources being destroyed and recreated instead of updated in place.

Hi John,

It looks like the service was not imported correctly and therefore it doesn’t find an existing match to update and instead, it is creating a new one.

In your example, you referenced enforce_service. So, in your example, there should first be a service resource called enforce_service in a .tf file within your terraform workspace.

You can then confirm that the service was imported into terraform using terraform show. You can also navigate to the .tf where the original resource "pagerduty_service" "enforce_service" {} was defined. It should now populate with all the services data it got from importing.

After you have confirmed that the service is correctly imported, you will need to remove the arguments that are read-only (any arguments not in this list: https://registry.terraform.io/providers/pagerduty/pagerduty/latest/docs/resources/service#argument-reference).

Thanks,

Abbott Brannon