Mastercard / terraform-provider-restapi

A terraform provider to manage objects in a RESTful API
Other
785 stars 215 forks source link

Delete API not triggered on destroy (redux) #249

Open shawnchapla-8451 opened 7 months ago

shawnchapla-8451 commented 7 months ago

I've also run into a similar issue as described in this issue, working with an API which doesn't have a true "GET /other-things/{id}/things/{id}" URL for the pre-destroy read action. It has a general "GET /other-things/{id}/things" API which returns all resources of this type, including their IDs.

I've looked at whether I could use the read_path and read_search parameters of this provider, which I think would be something along the lines of:

resource "restapi_object" "thing" {
  for_each  = local.list-of-other-things
...
  path = "/other-things/${each.value}/things"
  read_path = "/other-things/${each.value}/things"
  read_search = {
    "search_key": "id",
    "search_value": "<ID returned on create of this resource>"
  }

However, I essentially need to be able to reference the current object (i.e., "self") to get the ID that was returned when it was created. Essentially I want to be able to allow the restapi provider to confirm that a resource exists so it can delete it with destroy.

It doesn't appear Terraform has any notion of "self" (at least that I can find), so wondering if there's another way this might be achieved with the features of this provider?