iLert / terraform-provider-ilert

ilert's Terraform provider
https://registry.terraform.io/providers/iLert/ilert/latest/docs
Other
9 stars 1 forks source link

Removing a service requires that service to be first removed from status page #47

Closed RomeroGaliza closed 1 year ago

RomeroGaliza commented 1 year ago

Currently, to remove a service the iLert API requires that the service must be first removed from any status page. This creates a cyclic dependency when removing a service from a status page when declaring both on the same terraform plan.

STLVRTX commented 1 year ago

Thank you for submitting this issue. Exactly, this behaviour of removing a service first from any status page is enforced by our API to prohibit a service from accidentally being removed from further status pages.

When removing a service from a status page in Terraform this API limitation initially does lead to problems because Terraform tries to delete the service first and then modify the status page. This default behaviour from Terraform has to be modified here by using the lifecycle block in the status page resource and set create_before_destroy = true. Reference

resource "ilert_status_page" "example" {
  lifecycle {
    create_before_destroy = true
  }

  name       = "example"
  subdomain  = "example.ilert.io"
  visibility = "PUBLIC"

  service {
    id = ilert_service.example.id
  }

  service {
    id = ilert_service.example2.id
  }
}

This way Terraform removes the service from the status page first and then destroys the service.

If there are any more problems regarding this please reopen this issue.